Reputation: 105133
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?
Upvotes: 3
Views: 5488
Reputation: 615
I think that Hibernate looks for classes in the same codesource as the persistence.xml. So, for example, if you have persistence.xml in a folder and classes in a separate jar, Hibernate won't find them.
Upvotes: 0
Reputation: 114797
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
Upvotes: 8
Reputation: 240928
Try Making it..like this
<property name="hibernate.archive.autodetection" value="class" />
Upvotes: 1