Uploaded image for project: 'Causeway'
  1. Causeway
  2. CAUSEWAY-2706

JPA does not persist entities with application-defined primary keys

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0-M5
    • 2.0.0-M6
    • Persistence JPA
    • None

    Description

      For example, secman's ApplicationTenancy cannot be persisted as currently implemented.

      Reason (perhaps): there is logic in ManagedObjects.EntityUtil.getState() to infer the entity state of the object, and for such entities it returns the state as PERSISTABLE_DESTROYED rather than DETACHED, meaning that flush transaction is never called. 

      To reproduce, simply attempt to create a new ApplicationTenancy. 

       

      HERE'S THE CODE THAT SHOWS the entity is not reported as detached,so the transaction never flushed:

       

      THE FIX MIGHT BE TO SIMPLY REMOVE THE HIGHLIGHTED, WHICH PERHAPS IS A PERFORMANCE OPTIMISATION?  (or,  it is only safe to do if the @Id also has @GeneratedValue, which application-defined primary keys do not, of course.

       

       

       

      Attachments

        1. image-2021-05-28-06-20-20-489.png
          274 kB
          Daniel Keir Haywood
        2. image-2021-05-28-06-31-55-731.png
          183 kB
          Daniel Keir Haywood

        Activity

          People

            hobrom Andi Huber
            danhaywood Daniel Keir Haywood
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: