Hi,
I am just starting with Jibx and I have a mapping issue I am struggling
to fix.
The case is the following:
Java:
- Class Descriptive (id,value,description);
- About 20 classes that extend Descriptive (eg: Rank and Qualification).
I am mapping them to the ORM Hibernate. Serializing sends the "value"
to the XML, but when deserializing I want to retrieve the actual object
from the database.
The problem is that the deserializer method only has the (String value)
signature, and I need the Class to fetch it from the database, like:
fetchFromDb(Rank.class, value);
The following implementation works:
<format
type="com.itclinical.pharmacovigilance.information.persistance.database.domain.descriptive.Qualification"
serializer="com.itclinical.pharmacovigilance.reporting.persistance.export.parser.Conversion.serializeDescriptive"
deserializer="com.itclinical.pharmacovigilance.reporting.persistance.export.parser.Conversion.deserializeQualification"/>
and
<value name="qualification" field="qualification" />
This means, however, that one needs to have "one format + one
deserializeX method" for each Descriptive implementation.
Is there a simpler alternative that I am not seeing?
Jibx expects the deserializeX method to return the actual
implementation, so returning a Descriptive doesn't work (binding will
fail). I've thought about having a custom Unmarshaller, but I can't seem
to understand if it'll work or how complicated it'll be.
For reference, my first solution to the binding/mapping problem was the
following (but I couldn't make the "fetch from db" part work, so I
abandoned it):
<mapping>
...
<structure field="qualification">
<structure name="qualification"
map-as=domain.descriptive.Qualification"/>
</structure>
</mapping>
(and in the end of that document:)
<mapping
class="domain.descriptive.Descriptive" abstract="true" >
<value name="field" field="value"></value>
</mapping>
<mapping class="descriptive.Qualification"
extends="descriptive.Descriptive" abstract="true">
<structure name="qualification"
map-as=domain.descriptive.Descriptive"/>
</mapping>
Your help will be greatly appreciated!
Miguel
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users