java - 如果我为 transient 变量提供列标记,在 hibernate 中会发生什么?

标签 java hibernate transient

如果我为 transient 变量提供列标记,在 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; 



}

最佳答案

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

JSR 220 Specification

If the entity has field-based access, the persistence provider runtime accesses instance variables directly. All non-transient instance variables that are not annotated with the Transient annotation are persistent.

关于java - 如果我为 transient 变量提供列标记,在 hibernate 中会发生什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26288327/

相关文章:

java - 线程 "Thread-6"kotlin.UninitializedPropertyAccessException : lateinit property has not been initialized 中的 xception

java - 如何使用 hibernate session 方法更新映射实体类的实例?

java - 如何在持久化之前根据 transient 属性计算持久化属性?

java - java中可以通过反射设置字段的 transient 属性/标志吗?

java - 两种类型的 try catch block 之间的区别

java - 无法使用具有通用扩展 Number 的接口(interface)

hibernate - hibernate 列表与4个表不同

hibernate - 无法将数据库状态与 session 同步

hibernate - JBoss Hibernate 库冲突

java - Selenium TestNG 页面对象模型框架中的问题