Description
In a command line application running with Cayenne agent , the following code would result in exceptions about Artist not being persistent:
Class.forName("test.Artist");
EntityManagerFactory emf = Persistence
.createEntityManagerFactory("cayenne-tutorial");
EntityManager em = emf.createEntityManager();
tx = em.getTransaction();
tx.begin();
em.createQuery("delete from Artist").executeUpdate();
Since redefining already loaded classes is not possible (instrumentation spec prohibits adding fields to such classes for instance), the only solution I see is to trigger PersistentUnit loading from within the agent. I am going to make it optional as it slows down app startup. This will be an agent parameter "jpa-eager-load"