关闭

Hibernate异常:NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/

标签: hibernate异常
1711人阅读 评论(0) 收藏 举报
分类:

在进行JUnit4测试时,抛异常:

Caused by: java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;

at org.hibernate.cfg.AnnotationBinder.bindManyToOne(AnnotationBinder.java:2881)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1795)
at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:963)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:796)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3788)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3742)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1410)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:343)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:431)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:416)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)

... 53 more


Hibernate异常,之前在另一台电脑上处理过,转移到新电脑就又出现了。

原因是:我用的是Hibernate4.3.5,JavaEE5,hibernate-jpa-2.1-api-1.0.0.Final.jar包与javaee的persistence包冲突了。

解决办法:删掉javaee.jar包中的persistence文件


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:73133次
    • 积分:1400
    • 等级:
    • 排名:千里之外
    • 原创:65篇
    • 转载:21篇
    • 译文:0篇
    • 评论:4条