openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitry Pavlov (Created) (JIRA)" <j...@apache.org>
Subject [jira] [Created] (OPENJPA-2144) Using recursive relationships along with Identity Class leads to NullPointerException
Date Mon, 27 Feb 2012 12:13:49 GMT
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: 2.2.0, 2.1.1, 2.1.0, 2.0.1, 2.0.0, 1.2.2
            Reporter: Dmitry Pavlov


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<Node2> nodes = new ArrayList<Node2>();

                    // getters, setters, etc.
                    // full text will be attached as a unit test: TestRecursiveRelationshipsWithIdClass.testTree()

An attempt to use a such entity leads to:

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

        

Mime
View raw message