Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.9.6, 0.9.7
    • Fix Version/s: 2.0.0-M2
    • Component/s: kernel
    • Labels:
      None
    • Environment:
      Java 6

      Description

      When using an application id class containing a reference to another entity (example given below) a NPE is thrown when merging/reattaching the instance to an entity manager.
      The problem is caused by the involved AttachStrategy where on line 89 (pc.pcNewInstance(null, appId, false) the call to pcNewInstance is null for the first parameter (StateManager). This statemanager is used to retrieve the object reference when reattaching using the method pcCopyKeyFieldsFromObjectId in the pcNewInstance method.

      Source for this bug:

      @Entity
      @Table(name = "domain_record")
      @IdClass(DomainRecord.DomainRecordId.class)
      public class DomainRecord implements Serializable {

      private static final long serialVersionUID = 2966781630801201103L;

      public static class DomainRecordId implements Serializable {

      private static final long serialVersionUID = 3629556841694516032L;

      private String zone;

      private String name;

      private Type type;

      private String data;

      public DomainRecordId() {
      }

      public DomainRecordId(DomainRecord record)

      { this.zone = record.zone.getName(); this.name = record.name; this.type = record.type; this.data = record.data; }

      public DomainRecordId(String zone, String name, Type type, String data)

      { this.zone = zone; this.name = name; this.type = type; this.data = data; }

      /**

      • @see java.lang.Object#hashCode()
        */
        @Override
        public int hashCode() { final int PRIME = 31; int result = 1; result = PRIME * result + ((data == null) ? 0 : data.hashCode()); result = PRIME * result + ((name == null) ? 0 : name.hashCode()); result = PRIME * result + ((type == null) ? 0 : type.hashCode()); result = PRIME * result + ((zone == null) ? 0 : zone.hashCode()); return result; }

      /**

      • @see java.lang.Object#equals(java.lang.Object)
        */
        @Override
        public boolean equals(Object obj)
        Unknown macro: { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final DomainRecordId other = (DomainRecordId) obj; if (data == null) { if (other.data != null) return false; } else if (!data.equals(other.data)) return false; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; if (type == null) { if (other.type != null) return false; } else if (!type.equals(other.type)) return false; if (zone == null) { if (other.zone != null) return false; } else if (!zone.equals(other.zone)) return false; return true; }

      }

      /**

      • @author markusw
      • @version $Revision$
        */
        public enum Type { A, AAAA, ALIAS, CNAME, HINFO, MX, NAPTR, NS, PTR, RP, SRV, TXT }

      @Id
      @ManyToOne(fetch = FetchType.LAZY, cascade =

      { CascadeType.ALL }

      )
      @JoinColumn(name = "domain", referencedColumnName = "name")
      private Domain zone;

      @Id
      @Column(length = 64)
      private String name;

      @Id
      @Enumerated(EnumType.STRING)
      private Type type;

      @Id
      @Column(length = 128)
      private String data;
      ...
      }

      1. OPENJPA-218.patch
        1 kB
        Fay Wang
      2. OPENJPA-218-testcase.patch
        14 kB
        Fay Wang

        Activity

        Donald Woods made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Fay Wang made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0.0 [ 12313483 ]
        Resolution Fixed [ 1 ]
        Fay Wang made changes -
        Attachment OPENJPA-218-testcase.patch [ 12404386 ]
        Fay Wang made changes -
        Field Original Value New Value
        Attachment OPENJPA-218.patch [ 12404377 ]
        Markus Wolf created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Markus Wolf
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development