2014-10-09 26 views
0

如果我给出一个瞬变变量的列标签,在hibernate中会发生什么?如果我给出一个瞬变变量的列标记,会发生什么?

@Table(name="team") 
public class Team extends BaseObject implements Serializable { 

@Id @GeneratedValue(strategy=GenerationType.AUTO) 
private Long id; 

@Column(length=50) 
private String name; 

@Column(length=10) 
private String code; 

@Column(name = "agency_id") 
private Long agencyId; 

@Column(name = "agency_name") 
private transient String agencyName; 



} 
+0

这里是讨论,http://stackoverflow.com/questions/4662582/how-to-make-hibernate-ignore-class-variables-that-are-not-mapped。 – 2014-10-09 21:56:01

+0

您是否正在谈论'transient'字符串代理名称'隐含的'transient'(一个关键字)?如果是这样,该字段将不会被序列化。但是,如果你在谈论注解'@Transient'('javax.persistence.Transient'),那么该字段将不会被持久化到数据库中(也不会检索它的值 - 不必提及)。 – Tiny 2015-01-24 21:59:31

回答

1

字段不是持久的。您将不会从数据库获取字段值,更改将不会被提交。

JSR 220 Specification

如果实体有基于字段的访问,持久性提供运行时直接访问实例变量。所有非暂时性的实例变量都没有使用瞬态注释进行注释,它们是持久性的。

相关问题