MTR*_*MTR 37 java hibernate deprecated
我试图更新到Hibernate 4,我得到org.hibernate.annotations.Entity已被弃用.然而,没有任何文件表明情况就是如此.有人对此有任何见解吗?
@org.hibernate.annotations.Entity(dynamicUpdate = true)
Run Code Online (Sandbox Code Playgroud)
tol*_*ius 36
是的,它已在4.0+中弃用:
Deprecate org.hibernate.annotations.Entity
Its individual attributes/values should become annotations.
Schedule for removal in 4.1
Run Code Online (Sandbox Code Playgroud)
您应该使用@DynamicUpdate,而不是
这是一个固定的JIRA谈论它.
小智 8
该
@javax.persistence.Entity注释被用于标记类作为一个实体.它的功能与第2.3节"映射文件"中讨论的类映射元素相同.此外,@javax.persistence.Table注释显式指定表名.如果没有此规范,默认表名称将为EVENT).
由于不推荐使用org.hibernate.annotations.Entity,因此应使用Java EE注释.此外,正如tolitius已经提到的,对于注释配置@org.hibernate.annotations.Entity,您应该使用相应的注释,例如@DynamicUpdate.
希望有所帮助.
注意:Event是示例中注释的类的名称,这就是为什么它声明"默认表名称将是EVENT".
小智 6
使用 JPA @Entity 注释而不是 Hibernate @Entity 注释。看看你的进口,它应该说
import javax.persistence.Entity;
Run Code Online (Sandbox Code Playgroud)
并不是
import org.hibernate.annotations.Entity;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
37711 次 |
| 最近记录: |