openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pinaki Poddar (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OPENJPA-451) org.apache.openjpa.util.GeneralException: null at org.apache.openjpa.kernel.BrokerImpl.embed(BrokerImpl.java:2645)
Date Thu, 19 Jun 2008 16:19:46 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-451?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12606432#action_12606432
] 

Pinaki Poddar commented on OPENJPA-451:
---------------------------------------

Attribute class has declared a field named 'data' of type Data. And Data is a MappedSuperClass.
According to JPA specification, however, "a mapped superclass cannot be the target of a persistent
relationship".
Attribute.data is a relationship which may or may not be embdded from a mapping perspective.

This may explain why when type of the field 'Attribute.data' is changed to DataString which
is a *not* a mapped superclass -- everything works.

> org.apache.openjpa.util.GeneralException: null at org.apache.openjpa.kernel.BrokerImpl.embed(BrokerImpl.java:2645)
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-451
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-451
>             Project: OpenJPA
>          Issue Type: Test
>    Affects Versions: 1.0.0
>         Environment: Windows Vista, Intel Core 2 Duo, 1gb RAM
>            Reporter: Sebastian Souza
>            Assignee: Pinaki Poddar
>            Priority: Minor
>
> 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!

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message