Details
Description
In the recent version 1.1 there is a change in behaviour for references to classes with id.
As a result, a mapping that was working before (e.g. in version 1.0.5) causes an exception.
Here is sample mapping:
<?xml version="1.0"?>
<mapping>
<class name="sample.Identifiable"
verify-constructable="false" identity="id">
<map-to xml="Identifiable" />
<field name="id" type="string">
<bind-xml name="id" node="attribute" />
</field>
</class>
<class name="sample.Person" extends="sample.Identifiable" >
<map-to xml="Person" />
<field name="name" type="string">
<bind-xml name="name" node="attribute" />
</field>
</class>
<class name="sample.Department">
<map-to xml="Department" />
<field name="members" type="sample.Person" collection="arraylist">
<bind-xml name="members" node="attribute"
reference="true"/>
</field>
</class>
</mapping>
Previously, the mapping led to
<?xml version="1.0" encoding="UTF-8"?>
<Department members="id-1 id-2"/>
but in the recent version, the following exception is thrown.
Unable to resolve ID for instance of class 'sample.Person' due to the following error: No identity descriptor available
at
org.exolab.castor.xml.Marshaller.getObjectID(Marshaller.java:2018)
at
org.exolab.castor.xml.Marshaller.processAttribute(Marshaller.java:2292)
at
org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:1351)
at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:840)
at
sample.CastorMappingIdTest.testCompatibility_2(CastorMappingIdTest.java:
59)
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:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
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 junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUn
it3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.ja
va:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:196)
The complete test case is attached. Mapping file map1.xml gives the expected result, while map2.xml fails.
Activity
| Field | Original Value | New Value |
|---|---|---|
| Assignee | Werner Guttmann [ wguttmn ] |
| Fix Version/s | 1.1.1 [ 13080 ] |
| Attachment | patch.c1869.20070218.txt [ 25774 ] |
| Resolution | Fixed [ 1 ] | |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Status | Resolved [ 5 ] | Closed [ 6 ] |
Initial patch for review.