Hello,
please, help me, I've an issue during the unmarshalling process of an xml with
identities and references. The problem is not easy for me and attached to this
email there are some examples.
My domain model is this: I've a Map where there are: Locations, Elements and
Lines. In a single Location can be placed more then one single Element but one
Element refere to just a single Location (it's a 1 Location to N Elements
relation).
A set of Elements draw a Line and an Element can be part of different Lines
(it's a many Elements to many Lines relation).
In order to create a lighter xml, minimize the number of objects and respect the
fact that the modify of a location must be reflected in every Element placed in
that location I'm using identities and references in the mapping file.
The problem is that the id fields are unique just across all the objects of the
same type. So I've an integer id for Locations, Elements and Lines: all of them
start from 1.
So when the unmarshaller creates the relations it happens this exception:
java.lang.IllegalArgumentException:
Type conversion error: could not set value of location(Location) with value of
type ElectricElement at
org.exolab.castor.mapping.loader.FieldHandlerImpl.setValue(FieldHandlerImpl.java:521)
That's because the ids match, if I change my networkmap.xml using just unique
ids across all the file, then I've no exception!
The problem is that in my model I've three sets of id (as I said: for Location,
for Line and for Elements)...
So... tell me there is a way to get through all of this. Please! :|
Thanks anyway,
Ivan
--
Ivan Ricotti
-------------------------------------------
eLabor sc - via G. Garibaldi 33, 56127 Pisa
tel: +39 050970363 web: http://www.elabor.biz
email: [EMAIL PROTECTED]
GnuPG KeyID: DFD581C5 - 13/11/2003
<mapping>
<class name="NetworkMap">
<field name="locations" collection="collection" type="Location">
<bind-xml name="Location" node="element" />
</field>
<field name="elements" collection="collection"
type="ElectricElement">
<bind-xml name="ElectricElement" node="element" />
</field>
<field name="lines" collection="collection"
type="Line">
<bind-xml name="Line" node="element" />
</field>
</class>
<class name="Location" identity="id">
<map-to xml="Location" />
<field name="id" type="integer">
<bind-xml name="id" node="attribute" />
</field>
<field name="latitude" type="double">
<bind-xml name="Latitude" node="element" />
</field>
<field name="longitude" type="double">
<bind-xml name="Longitude" node="element" />
</field>
<field name="elements" type="ElectricElement" collection="collection">
<bind-xml name="ElectricElement" reference="true" />
</field>
</class>
<class name="ElectricElement"
identity="id">
<map-to xml="ElectricElement" />
<field name="id" type="integer">
<bind-xml name="id" node="attribute" />
</field>
<field name="location"
type="Location">
<bind-xml name="Location" reference="true" />
</field>
<field name="lines" type="Line"
collection="collection">
<bind-xml name="Line" reference="true" />
</field>
</class>
<class name="Line" identity="id">
<map-to xml="Line" />
<field name="id" type="integer">
<bind-xml name="id" node="attribute" />
</field>
<field name="elements" type="ElectricElement" collection="collection">
<bind-xml name="ElectricElement" reference="true" />
</field>
</class>
</mapping>
<NetworkMap>
<Location id="1">
<Latitude>5.0</Latitude>
<Longitude>2.0</Longitude>
<ElectricElement>1</ElectricElement>
</Location>
<Location id="2">
<Latitude>4.0</Latitude>
<Longitude>3.0</Longitude>
<ElectricElement>2</ElectricElement>
<ElectricElement>3</ElectricElement>
</Location>
<ElectricElement id="1">
<Location>1</Location>
<Line>1</Line>
</ElectricElement>
<ElectricElement id="2">
<Location>2</Location>
<Line>1</Line>
</ElectricElement>
<ElectricElement id="3">
<Location>2</Location>
<Line>1</Line>
</ElectricElement>
<Line id="1">
<ElectricElement>1</ElectricElement>
<ElectricElement>2</ElectricElement>
<ElectricElement>3</ElectricElement>
</Line>
</NetworkMap>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email