Hibernate - 忽略非注释字段而无需添加@Transient

标签 hibernate

有没有一种方法(配置参数)可以更改 Hibernate 默认行为以将域类的非注释字段视为持久化?

我希望 Hibernate 默认认为非注释字段是 transient 的,并且不能考虑持久性,而不是努力使用 @Transient 注释所有这些字段。

最佳答案

根据Hibernate Reference,Hibernate 注释看起来不可能。 :

In the annotations world, every non static non transient property (field or method depending on the access type) of an entity is considered persistent, unless you annotate it as @Transient. Not having an annotation for your property is equivalent to the appropriate @Basic annotation.

当然,对于 XML 映射,您可以只添加将被映射的属性。

关于Hibernate - 忽略非注释字段而无需添加@Transient,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21431995/

相关文章:

java - Spring 规范和可分页

java - hibernate 中的 save() 和 persists() 方法在级联方面有什么区别?

sql - 如何使用executeUpdate()删除具有GORM(Grails)和HQL(Hibernate)的实体

java - 为什么在类似搜索期间将 lower 添加到 hibernate 查询中

java - 了解注解和 JPA(hibernate)

java - 测试 Hibernate 映射 : no persistent classes found for query classes

java - 如果嵌入组件,Hibernate 不会创建实体表

java - Hibernate 在哪里放classname.hbm.xml

java - 对于每个代码更改都需要导出 war 并重新启动服务器

hibernate - hibernate 如何填充实体