在@Entity时很容易顺手导入@org.hibernate.annotations.Entity这个包,结果导致了异常。其实应该导入的是@javax.persistence.Entity
Always import @javax.persistence.Entity
@org.hibernate.annotations.Entity是@javax.persistence.Entity的一个补充,但不是后者的替代品
如果import @org.hibernate.annotations.Entity的话,会报异常。
如果想使用@org.hibernate.annotations.Entity所包含的特殊的功能的话,需要在import @javax.persistence.Entity的基础上增加注释,如下:
@Entity
@org.hibernate.annotations.Entity(optimisticLock=OptimisticLockType.ALL)
public class MyEntity implements Serializable {
...
}
相关推荐
搭建mybatis所需包org.apache.ibatis.annotations.Param @Param
hibernate-commons-annotations-4.0.1.Final.jar hibernate-core-4.1.12.Final.jar hibernate-ehcache-4.1.12.Final.jar hibernate-entitymanager-4.1.12.Final.jar hibernate-jpa-2.0-api-1.0.1.Final.jar ...
NULL 博文链接:https://xiongjiajia.iteye.com/blog/1947270
hibernate-commons-annotations-4.0.1.Final.jar
hibernate-annotations-3.4.0.GA hibernate-annotations-3.4.0.GA hibernate-annotations-3.4.0.GA
myeclipse的自带hibernate jar包不支持注解;自己找的hibernate注解所需的jar包:hibernate-core;hibernate-annotation;hbm-cfg-xml;log4j.properties
hibernate-commons-annotations-5.1.0.Final.jar
包含: hibernate3.jar; hibernate3-annotations.jar; hibernate3-commons-annotations.jar
jar包,官方版本,自测可用
jar包,官方版本,自测可用
jar包,官方版本,自测可用
jar包,官方版本,自测可用
jar包,官方版本,自测可用
解压后可得hibernate-annotations.jar和hibernate-annotations-src.zip,hibernate-annotations-src.zip为hibernate-annotations.jar的源代码
jar包,官方版本,自测可用
jar包,官方版本,自测可用
使用注解Annotation时用的jar包。 包括: hibernate-commons-annotations-3.3.0.ga.jar hibernate-entitymanager.jar ejb3-persistence.jar hibernate-annotations.jar
现在已经不用*.hbm.xml这种映射文件了,都是用Annotation(注解)方式来完成实体与表之间的映射关系,这样看起来比用xml文件来映射更具有可读性,自我感觉以后Hibernate Annotation的映射方式将代替hibernate 的*....
hibernate-commons-annotations-5.0.1.Final.jar的源码
org.springframework.roo.annotations package and pom for maven project