LocalContainerEntityManagerFactoryBean, Hibernate and superflous tables created in wrong database

TL;DR 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 … Continue reading LocalContainerEntityManagerFactoryBean, Hibernate and superflous tables created in wrong database

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)

ID trouble with multiple Hibernate entities on the same table

Just a while ago I ran into a case where Hibernate would auto generate a wrong database schema when two entities were mapped on the same table. The good news: it's my fault and not a bug. The better news: here's an account of how to avoid it. Let's assume a mutable entity A mapped … Continue reading ID trouble with multiple Hibernate entities on the same table