Hibernate’s (3.2-3.4) JPA implementation will pick up hbm files on it’s own when it should be looking only at persistence.xml, thus:
– loading more entities that it should
– loading the wrong entities
– performing schema updates in the wrong database
This one annoyed me plenty and took a great deal of debugging to sort out.
My spring application uses both JPA and plain Hibernate (on purpose), thus there is an EntityManager and a SessionFactory floating around.
– is obtained via a LocalContainerEntityManagerFactoryBean
– is configured via META-INF/persistence.xml
– uses exclusively @Entity annotations on beans
– obtained via a LocalSessionFactoryBean
– reads entities from a bunch of hbm files (in a specially hidden, non-standard location in the classpath)
– doesn’t use annotations
I noticed that the JPA database would contain empty tables which corresponded to entities from the other Hibernate database. They would never contain any data, yet after dropping the hibernate tables from the JPA database, they would appear again after every restart.
Either make sure hbm files are not in the classpath, or give the LocalContainerEntityManagerFactoryBean a void mapping, ie:
Where dummy-mapping-dont-delete.xml can be an almost empty persistence.xml: