views:

35

answers:

3

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?

A: 
  1. Do you have @Entity on your class?
  2. Are you sure you are using this particular persistence unit?
Bozho
+1  A: 

Try Making it..like this

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

Documentations

org.life.java
+2  A: 

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

Andreas_D
class is enough i think for his case.no hbm required
org.life.java