The problem could be my expectation, since I'm fairly inexperienced with JPA. But here is the problem:
The base class of my entity hierarchy is annotated as @MappedSuperclass, and one of its fields is annotated @Transient. I expected that when I persist a subclass, no table would be created for the superclass, and the transient field would not appear in any table.
The actual result is that there is a table for the superclass. When I try to examine it in ObjectDB Explorer, it throws a NPE. And there is a column in the subclass table named for the transient field. All its values are null.
Here is my base class:
package krum.twj.db; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.MappedSuperclass; import javax.persistence.Transient; import javax.persistence.Version; @MappedSuperclass public class DataObject { @Id @GeneratedValue protected int id; @Version protected long version; @Transient protected EntityManagerFactory emf; protected DataObject merge() { //System.err.println("Saving " + this.getClass() + " id " + id + " version " + version); EntityManager em = emf.createEntityManager(); em.getTransaction().begin(); DataObject merged = em.merge(this); em.getTransaction().commit(); em.close(); //System.err.println("Got back id " + merged.id + " version " + merged.version); merged.emf = emf; return merged; } }