Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-859

Cayenne agent misses JPA entity classes that were loaded before their PersistenceUnits

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0
    • 3.0M2, 3.0
    • None
    • None

    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"

      Attachments

        Activity

          People

            andrus Andrus Adamchik
            andrus Andrus Adamchik
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: