1. OpenJPA
  2. OPENJPA-286

Can't merge detached One-To-Many child instance. The entities were implement by an internal Hash container.


    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.9.7, 1.0.0, 1.1.0
    • Fix Version/s: 1.2.0
    • Component/s: jdbc
    • Labels:
    • Environment:
      java version "1.5.0_10"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
      Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode, sharing)


      Maybe you know, one of the entity implementation is composite of a hash set, which stores key-value pairs.

      It's a common design of Entity Bean in EJB2.x ages. Does any one use it in OpenJPA? I am using it right now, and encounter an issue in entity cascade manipulate. Here is the issue description. : the super class of entities.
      protected final Object getAttributeValue(String attributeName)

      { return _values.get(attributeName); }

      protected final void setAttributeValue(String attributeName, Object value)

      { _values.put(attributeName, value); }

      // To hold the

      {attributeName, value}

      pair of the value object.
      private HashMap<String, Object> _values = new HashMap<String, Object>(); extends : Entity C has a set of Entity D.
      public void setDs(Set<D> ds)

      { setCollection("Ds", ds); }

      @OneToMany(mappedBy = "c", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
      public Set<D> getDs()

      { return (Set<D>)getAttributeValue("Ds"); } extends as well.

      The relationship between C and D is one-to-many. I use following code to reproduce the issue.

      C c = em.find(C.class, 1);
      D d = new D();

      After commit the transaction, you will find the new D instance was not inserted into the database(there is no insert sql log as well). After you add, em.persist(c). That new instance will be added!

      Meanwhile, I wrote a couple of classes, which do not use a HashSet. I got the expected result after merge is done.


        Donald Woods made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Michael Dick made changes -
        Fix Version/s 1.2.0 [ 12313102 ]
        Pinaki Poddar made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Pinaki Poddar made changes -
        Assignee Pinaki Poddar [ ]
        Gene Wu made changes -
        Field Original Value New Value
        Attachment [ 12362119 ]
        Gene Wu created issue -


          • Assignee:
            Pinaki Poddar
            Gene Wu
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: