From dev-return-20249-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Tue Feb 28 05:25:14 2012 Return-Path: X-Original-To: apmail-openjpa-dev-archive@www.apache.org Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2D54292B5 for ; Tue, 28 Feb 2012 05:25:14 +0000 (UTC) Received: (qmail 61185 invoked by uid 500); 28 Feb 2012 05:25:14 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 60907 invoked by uid 500); 28 Feb 2012 05:25:11 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 60876 invoked by uid 99); 28 Feb 2012 05:25:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Feb 2012 05:25:10 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Feb 2012 05:25:08 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id B52CC33E089 for ; Tue, 28 Feb 2012 05:24:48 +0000 (UTC) Date: Tue, 28 Feb 2012 05:24:48 +0000 (UTC) From: "Dmitry Pavlov (Issue Comment Edited) (JIRA)" To: dev@openjpa.apache.org Message-ID: <1598351468.26701.1330406688743.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <464101975.22833.1330344829303.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Issue Comment Edited] (OPENJPA-2144) Using recursive relationships along with Identity Class leads to NullPointerException MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-2144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13217165#comment-13217165 ] Dmitry Pavlov edited comment on OPENJPA-2144 at 2/28/12 5:23 AM: ----------------------------------------------------------------- Node2.java - full implementation of an entity class shown in the issue description. TestRecursiveRelationshipsWithIdClass.java - unit test for the issue. Provided unit test demonstrates the issue ( see testTree() ). It also shows query problems while using "Identity Class" (see testPreparedSQLQueryToTree(), see OPENJPA-2147). was (Author: dmitry.pavlov): Node2.java - full implementation of an entity class shown in the issue description. TestRecursiveRelationshipsWithIdClass.java - unit test for the issue. Provided unit test demonstrates the issue ( see testTree() ). It also shows query problems while using "Identity Class" (see testPreparedSQLQueryToTree()). > Using recursive relationships along with Identity Class leads to NullPointerException > ------------------------------------------------------------------------------------- > > Key: OPENJPA-2144 > URL: https://issues.apache.org/jira/browse/OPENJPA-2144 > Project: OpenJPA > Issue Type: Bug > Components: jdbc > Affects Versions: 1.2.2, 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.2.0 > Reporter: Dmitry Pavlov > Attachments: TestRecursiveRelationshipsWithIdClass.jar, openjpa-2144-trunk.patch > > > Partially defined entity: > @Entity > @IdClass(Node2.ID.class) > public class Node2 { > @Id > @GeneratedValue > private long id; > @Id private int region = 1; > @Id private int district = 2; > @ManyToOne(fetch = LAZY) > @JoinColumns({ > @JoinColumn(name = "PARENT_ID", referencedColumnName = "ID"), > @JoinColumn(name = "REGION", referencedColumnName = "REGION"), > @JoinColumn(name = "DISTRICT", referencedColumnName = "DISTRICT") }) > private Node2 parent; > @OneToMany(mappedBy = "parent", cascade = ALL, fetch = LAZY) > private List nodes = new ArrayList(); > // getters, setters, etc. > // full text will be attached as a unit test: TestRecursiveRelationshipsWithIdClass.testTree() > An attempt to use a such entity leads to NullPointerException : > FailedObject: org.apache.openjpa.persistence.recursive.idclass.Node2-1151::1::2 [java.lang.String] > at org.apache.openjpa.kernel.BrokerImpl.refreshInternal(BrokerImpl.java:3107) > at org.apache.openjpa.kernel.BrokerImpl.refresh(BrokerImpl.java:2998) > at org.apache.openjpa.kernel.DelegatingBroker.refresh(DelegatingBroker.java:1134) > at org.apache.openjpa.persistence.EntityManagerImpl.refresh(EntityManagerImpl.java:780) > at org.apache.openjpa.persistence.EntityManagerImpl.refresh(EntityManagerImpl.java:757) > at org.apache.openjpa.persistence.recursive.idclass.TestRecursiveRelationshipsWithIdClass.setUpInitialTree(TestRecursiveRelationshipsWithIdClass.java:130) > at org.apache.openjpa.persistence.recursive.idclass.TestRecursiveRelationshipsWithIdClass.testPreparedSQLQueryToTree(TestRecursiveRelationshipsWithIdClass.java:92) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:600) > at junit.framework.TestCase.runTest(TestCase.java:154) > at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.runTest(AbstractPersistenceTestCase.java:579) > at junit.framework.TestCase.runBare(TestCase.java:127) > at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.runBare(AbstractPersistenceTestCase.java:566) > at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.runBare(AbstractPersistenceTestCase.java:542) > at junit.framework.TestResult$1.protect(TestResult.java:106) > at junit.framework.TestResult.runProtected(TestResult.java:124) > at junit.framework.TestResult.run(TestResult.java:109) > at junit.framework.TestCase.run(TestCase.java:118) > at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.run(AbstractPersistenceTestCase.java:206) > at junit.framework.TestSuite.runTest(TestSuite.java:208) > at junit.framework.TestSuite.run(TestSuite.java:203) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:600) > at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213) > at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115) > at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:102) > at org.apache.maven.surefire.Surefire.run(Surefire.java:180) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:600) > at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350) > at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021) > Caused by: java.lang.NullPointerException > at org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.fetchLongField(ApplicationIds.java:669) > at org.apache.openjpa.persistence.recursive.idclass.Node2.pcCopyKeyFieldsToObjectId(Node2.java) > at org.apache.openjpa.enhance.PCRegistry.copyKeyFieldsToObjectId(PCRegistry.java:171) > at org.apache.openjpa.util.ApplicationIds.fromPKValues(ApplicationIds.java:224) > at org.apache.openjpa.jdbc.meta.ClassMapping.getObjectId(ClassMapping.java:223) > at org.apache.openjpa.jdbc.meta.ClassMapping.getObjectId(ClassMapping.java:147) > at org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.load(RelationFieldStrategy.java:736) > at org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:928) > at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1094) > at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1038) > at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:659) > at org.apache.openjpa.util.ImplHelper.loadAll(ImplHelper.java:107) > at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.loadAll(JDBCStoreManager.java:695) > at org.apache.openjpa.kernel.DelegatingStoreManager.loadAll(DelegatingStoreManager.java:122) > at org.apache.openjpa.kernel.BrokerImpl.refreshInternal(BrokerImpl.java:3071) > ... 36 more -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira