Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 29109 invoked from network); 17 Apr 2007 14:51:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Apr 2007 14:51:39 -0000 Received: (qmail 94151 invoked by uid 500); 17 Apr 2007 14:51:43 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 94127 invoked by uid 500); 17 Apr 2007 14:51:43 -0000 Mailing-List: contact open-jpa-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: open-jpa-dev@incubator.apache.org Delivered-To: mailing list open-jpa-dev@incubator.apache.org Received: (qmail 94102 invoked by uid 99); 17 Apr 2007 14:51:43 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Apr 2007 07:51:43 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Apr 2007 07:51:35 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 8EC2C71406C for ; Tue, 17 Apr 2007 07:51:15 -0700 (PDT) Message-ID: <5005577.1176821475581.JavaMail.jira@brutus> Date: Tue, 17 Apr 2007 07:51:15 -0700 (PDT) From: "Markus Wolf (JIRA)" To: open-jpa-dev@incubator.apache.org Subject: [jira] Commented: (OPENJPA-218) pcNewInstance and ApplicationId In-Reply-To: <4876852.1176820815711.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-218?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489418 ] Markus Wolf commented on OPENJPA-218: ------------------------------------- To be more complete I'll attach the NPE stacktrace: java.lang.NullPointerException at de.esw.services.model.DomainRecord.pcCopyKeyFieldsFromObjectId(DomainRecord.java) at de.esw.services.model.DomainRecord.pcNewInstance(DomainRecord.java) at org.apache.openjpa.kernel.AttachStrategy.persist(AttachStrategy.java:89) at org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAttachStrategy.java:85) at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:236) at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:97) at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3124) at org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBroker.java:1120) at org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityManagerImpl.java:591) at org.springframework.orm.jpa.JpaTemplate$6.doInJpa(JpaTemplate.java:272) at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:191) at org.springframework.orm.jpa.JpaTemplate.merge(JpaTemplate.java:270) at de.esw.services.domain.DomainRecordProcessorImpl.update(DomainRecordProcessorImpl.java:53) > pcNewInstance and ApplicationId > ------------------------------- > > Key: OPENJPA-218 > URL: https://issues.apache.org/jira/browse/OPENJPA-218 > Project: OpenJPA > Issue Type: Bug > Components: kernel > Affects Versions: 0.9.6, 0.9.7 > Environment: Java 6 > Reporter: Markus Wolf > > 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) { > 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; > ... > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.