This is the second time this has bitten me: I want to use Hibernate with standard JPA to persist my entities. And I want my Entities autodetected, as Hibernate is capable of, even outside of a JEE container. So in my
persistence.xmlI have this bit of code:
<property name="hibernate.archive.autodetection" value="class,hbm"/>
But, I do not compile this
persistence.xmlinto my .jar file, instead I just make it part of my classpath for my unit tests, thinking this will make things more flexible. And of course, this doesn’t work. The autodetection only works if the
persistence.xmlis located in the
META-INFsection of the jarfile that contains the Entities to be detected. See my post in the Hibernate forum.