This is the case
Class Item {
private Collection<Attribute> attributes;
}
Class Attribute {
private Item item;
private Data data;
}
Class abstract Data {
public abstract Object getValue ();
public abstract void setValue (Object value);
}
Class DataString extends Data {
private String value;
public Object getValue () {return this.value;}
public void setValue (Object value) {this.value = (String)value;}
}
In my orm.xml i declare
<mapped-superclass class="Data">
<entity class="Item">
<attributes>
<one-to-many name="attributes" target-entity="Attribute" mapped-by="item">
<cascade>
<cascade-persist/>
</cascade>
</onte-to-many>
</attributes>
</entity>
<entitiy class="Attribute">
<attributes>
...
<embedded name="data">
</attributes>
</entity>
<embeddable class="DataString">
<attributes>
<basic name="value">
<column name ="data"/>
</basic>
</attributes>
</embeddable>
Data is persisted in Attribute table, so it has to be an embedded field
When i try to commit an Item in
getTransaction ().commit ();
239680 ITSM TRACE [main] openjpa.Runtime - An exception occurred while
ending the transaction. This exception will be re-thrown.
<openjpa-1.0.0-r420667:568756 nonfatal general error>
org.apache.openjpa.util.GeneralException: null
at org.apache.openjpa.kernel.BrokerImpl.embed(BrokerImpl.java:2645)
at
org.apache.openjpa.kernel.SingleFieldManager.embed(SingleFieldManager.java:847)
at
org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:588)
at
org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:562)
at
org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:478)
at
org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:2775)
at
org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:39)
at
org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:940)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1884)
at
org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1844)
at
org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1762)
at
org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1292)
at
org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:861)
at
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:408)
at
itsm.framework.persistence.business.PersistentObjectBusiness.insert(PersistentObjectBusiness.java:38)
at
itsm.framework.persistence.mappers.PersistentObjectMapper.create(PersistentObjectMapper.java:38)
at
itsm.configuration.mappers.ConfigurationItemVersionMapper.create(ConfigurationItemVersionMapper.java:33)
at
itsm.configuration.business.ConfigurationItemVersionBusiness.create(ConfigurationItemVersionBusiness.java:52)
at
itsm.configuration.facade.ConfigurationManagementFacade.createVersion(ConfigurationManagementFacade.java:711)
at
itsm.configuration.test.TestConfigurationItemVersion.testCreateWithAttributesWithoutRelationships(TestConfigurationItemVersion.java:123)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.NullPointerException
at org.apache.openjpa.kernel.BrokerImpl.embed(BrokerImpl.java:2623)
... 39 more
If i change my code to
Class Item {
private Collection<Attribute> attributes;
}
Class Attribute {
private Item item;
private DataString data; // Reference to a specialization class
}
Everything works fine!
Craig L Russell wrote:
>
> Hi Sebastian,
>
> Could you attach a test case to a new JIRA issue demonstrating the
> problem?
>
> For better ease of use, I'd like to see a nicer error message instead
> of a GeneralException.
>
> Thanks,
>
> Craig
>
> On Nov 24, 2007, at 11:47 AM, Sebastian Souza wrote:
>
>>
>> I found a solution to my problem
>>
>> my embedded field was a type Data (a mapped supper class), but the
>> embeddable class is a specialization of that class.
>>
>> i change that my embedded field to be a specialization class and
>> works!
>>
>> the embedded field can not be a mapped super class?
>>
>> sorry about my bad english
>>
>>
>> Sebastian Souza wrote:
>>>
>>> the exception is thrown when i do entityManager.getTransaction
>>> ().commit
>>> ();
>>>
>>> i'm trying to persist an object that has a collection with an
>>> embbeded
>>> field inside
>>>
>>> 239680 ITSM TRACE [main] openjpa.Runtime - An exception
>>> occurred while
>>> ending the transaction. This exception will be re-thrown.
>>> <openjpa-1.0.0-r420667:568756 nonfatal general error>
>>> org.apache.openjpa.util.GeneralException: null
>>> at org.apache.openjpa.kernel.BrokerImpl.embed(BrokerImpl.java:2645)
>>> at
>>> org.apache.openjpa.kernel.SingleFieldManager.embed
>>> (SingleFieldManager.java:847)
>>> at
>>> org.apache.openjpa.kernel.SingleFieldManager.preFlush
>>> (SingleFieldManager.java:588)
>>> at
>>> org.apache.openjpa.kernel.SingleFieldManager.preFlush
>>> (SingleFieldManager.java:562)
>>> at
>>> org.apache.openjpa.kernel.SingleFieldManager.preFlush
>>> (SingleFieldManager.java:478)
>>> at
>>> org.apache.openjpa.kernel.StateManagerImpl.preFlush
>>> (StateManagerImpl.java:2775)
>>> at org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:
>>> 39)
>>> at
>>> org.apache.openjpa.kernel.StateManagerImpl.beforeFlush
>>> (StateManagerImpl.java:940)
>>> at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1884)
>>> at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:
>>> 1844)
>>> at
>>> org.apache.openjpa.kernel.BrokerImpl.beforeCompletion
>>> (BrokerImpl.java:1762)
>>> at
>>> org.apache.openjpa.kernel.LocalManagedRuntime.commit
>>> (LocalManagedRuntime.java:81)
>>> at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1292)
>>> at
>>> org.apache.openjpa.kernel.DelegatingBroker.commit
>>> (DelegatingBroker.java:861)
>>> at
>>> org.apache.openjpa.persistence.EntityManagerImpl.commit
>>> (EntityManagerImpl.java:408)
>>> at
>>> itsm.framework.persistence.business.PersistentObjectBusiness.insert
>>> (PersistentObjectBusiness.java:38)
>>> at
>>> itsm.framework.persistence.mappers.PersistentObjectMapper.create
>>> (PersistentObjectMapper.java:38)
>>> at
>>> itsm.configuration.mappers.ConfigurationItemVersionMapper.create
>>> (ConfigurationItemVersionMapper.java:33)
>>> at
>>> itsm.configuration.business.ConfigurationItemVersionBusiness.create
>>> (ConfigurationItemVersionBusiness.java:52)
>>> at
>>> itsm.configuration.facade.ConfigurationManagementFacade.createVersion
>>> (ConfigurationManagementFacade.java:711)
>>> at
>>> itsm.configuration.test.TestConfigurationItemVersion.testCreateWithAt
>>> tributesWithoutRelationships(TestConfigurationItemVersion.java:123)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>> at java.lang.reflect.Method.invoke(Unknown Source)
>>> at junit.framework.TestCase.runTest(TestCase.java:168)
>>> at junit.framework.TestCase.runBare(TestCase.java:134)
>>> at junit.framework.TestResult$1.protect(TestResult.java:110)
>>> at junit.framework.TestResult.runProtected(TestResult.java:128)
>>> at junit.framework.TestResult.run(TestResult.java:113)
>>> at junit.framework.TestCase.run(TestCase.java:124)
>>> at junit.framework.TestSuite.runTest(TestSuite.java:232)
>>> at junit.framework.TestSuite.run(TestSuite.java:227)
>>> at
>>> org.junit.internal.runners.JUnit38ClassRunner.run
>>> (JUnit38ClassRunner.java:81)
>>> at
>>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run
>>> (JUnit4TestReference.java:38)
>>> at
>>> org.eclipse.jdt.internal.junit.runner.TestExecution.run
>>> (TestExecution.java:38)
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
>>> (RemoteTestRunner.java:460)
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
>>> (RemoteTestRunner.java:673)
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run
>>> (RemoteTestRunner.java:386)
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main
>>> (RemoteTestRunner.java:196)
>>> Caused by: java.lang.NullPointerException
>>> at org.apache.openjpa.kernel.BrokerImpl.embed(BrokerImpl.java:2623)
>>> ... 39 more
>>>
>>
>> --
>> View this message in context: http://www.nabble.com/
>> org.apache.openjpa.util.GeneralException%3A-null-at-
>> org.apache.openjpa.kernel.BrokerImpl.embed%28BrokerImpl.java%3A2645%
>> 29-tf4867049.html#a13928477
>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>
>
> Craig Russell
> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
> 408 276-5638 mailto:[EMAIL PROTECTED]
> P.S. A good JDO? O, Gasp!
>
>
>
>
--
View this message in context:
http://www.nabble.com/org.apache.openjpa.util.GeneralException%3A-null-at-org.apache.openjpa.kernel.BrokerImpl.embed%28BrokerImpl.java%3A2645%29-tf4867049.html#a13935585
Sent from the OpenJPA Users mailing list archive at Nabble.com.