Uploaded image for project: 'DeltaSpike'
  1. DeltaSpike
  2. DELTASPIKE-673

CdiQueryInvocationContext#isNew does not work well with OpenJpa and detached entities

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0.0
    • 1.4.2
    • Data-Module
    • None

    Description

      I'm trying to use org.apache.deltaspike.data.api.EntityRepository on TomEE 1.5.2 with detached entities. Whenever I try to call the save method of EntityRepository I get

      org.apache.openjpa.persistence.EntityExistsException: Attempt to persist detached object
      

      CdiQueryInvocationContex#isNew returns true for my detached entity and and because of that EntityManager#persist is called.

      see org.apache.deltaspike.data.impl.handler.EntityRepositoryHandler#save

      From OpenJpaPersistenceUtil#getIdentifier(OpenJPAEntityManagerFactory emf, Object entity)

          /**
           * Get the object identifier for a persistent entity managed by one
           * of the entity managers of the specified entity manager factory.
           * @return The identifier of the entity or null if the entity does
           * not have an identifier assigned or is not managed by any of the
           * entity managers of the entity manager factory.
           */
      

      Attachments

        Activity

          People

            danielsoro Daniel Cunha
            philip69 Philip Herbst
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: