为什么我的JPA注释类没有隐式发现? [英] why my JPA annotated classes are not discovered implicitly?

查看:97
本文介绍了为什么我的JPA注释类没有隐式发现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 persistence.xml 看起来像:

 <持续性>> ; 
< persistence-unit name =test>
< provider> org.hibernate.ejb.HibernatePersistence< / provider>
< class> com.XXX.Abc< / class>
<属性>
< property name =hibernate.archive.autodetectionvalue =true/>
..
< / properties>
< / persistence-unit>
<持久性>

一切正常。当我删除< class> 指令时,我收到了一个来自 EntityManager.find(Abc.class,1)
$ p $ java.lang.IllegalArgumentException:未知实体:com.XXX.Abc

虽然我使用 @Entity ..为什么?

解决方案 hibernate.archive.autodetection 是由hibernate自动发现的csv列表元素。



试试这个:

 < property name =hibernate.archive.autodetectionvalue =class,hbm/> 






进一步阅读




My persistence.xml looks like:

<persistence>
  <persistence-unit name="test">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>com.XXX.Abc</class>
    <properties>
      <property name="hibernate.archive.autodetection" value="true" />
      ..
    </properties>
  </persistence-unit>
<persistence>

Everything works fine. When I'm removing <class> directive I'm getting an exception from EntityManager.find(Abc.class, 1):

java.lang.IllegalArgumentException: Unknown entity: com.XXX.Abc

Looks like hibernate can't discover my annotated classes although I'm using @Entity.. Why?

解决方案

The value of the hibernate.archive.autodetection is a csv list of elements that are autodiscovered by hibernate.

Try this instead:

<property name="hibernate.archive.autodetection" value="class, hbm"/>


Further Reading

这篇关于为什么我的JPA注释类没有隐式发现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆