Category: jpa

LocalContainerEntityManagerFactoryBean, Hibernate and superflous tables created in wrong database

TL;DRHibernate'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 databaseThis one annoyed me plenty and took a great deal of debugging to sort out.The settingMy spring application … Continue reading LocalContainerEntityManagerFactoryBean, Hibernate and superflous tables created in wrong database

java.lang.NoClassDefFoundError: org/apache/openjpa/enhance/PersistenceCapable

My current project is using JPA, heavily. JPA is a spec/standard/interface and I'm using the Hibernate implementation for it, but I import the entities from a different maven module. The entities module has a dependency on JPA, but not on Hibernate. So when I run my unit tests, I suddenly get a:java.lang.NoClassDefFoundError: org/apache/openjpa/enhance/PersistenceCapableOpenjpa? Where does … Continue reading java.lang.NoClassDefFoundError: org/apache/openjpa/enhance/PersistenceCapable

On JPA identifiers and business keys (or why business keys are a bad idea)

JPA, and for that matter Hibernate, depends on identifying entity instances (I'll refer to them as entities for short) by some key. That key can either be a single property (like a numeric ID column in the corresponding table) or a business key (also referred to as natural key). Business keys are entity properties which … Continue reading On JPA identifiers and business keys (or why business keys are a bad idea)

Tomcat, Spring and memory leaks when undeploying or redeploying an web application

In this post I'll talk about a new kind of memory leak in Spring applications involving transaction management and initializing beans.About memory leaks when undeploying a web applicationWhile developing a web application with Spring and Tomcat I frequently run out of heap space. The web is full of stories about this. There is Aspirin to … Continue reading Tomcat, Spring and memory leaks when undeploying or redeploying an web application