hi,
i use the reference mechanism in my mapping file for reference a
concrete implementation of an abstract object. here is the codesnip:
J A V A:
public class Element{
private AbstractTemplate template; // with get- and set-method
// list of AbstractTemplates, with get- and set-method
private ArrayList templateList;
}
public abstract class AbstractTemplate{...}
public class BoxTemplate extends AbstractTemplate{...}
public class LineTemplate extends AbstractTemplate{...}
M A P P I N G:
<class name="BoxTemplate" identity="id">...</class>
<class name="LineTemplate" identity="id">...</class>
<class name="Element">
<field name="template" type="AbstractTemplate">
<bind-xml name="selected-template-id" node="attribute"
reference="true"/>
</field>
<field name="templateList" collection="arraylist"
type="AbstractTemplate">
<bind-xml name="available-template" node="element"/>
</field>
</class>
X M L:
<!-- the id's are unique in whole xml file -->
<box-template id="1">...</box-template>
<box-template id="2">...</box-template>
<line-template id="3">...</line-template>
<line-template id="4">...</line-template>
<element selected-template-id="1">
<available-template>1</available-template>
<available-template>2</available-template>
</element>
<element selected-template-id="3">
<available-template>3</available-template>
<available-template>4</available-template>
</element>
the single template attribute is unmarshalled with the concrete
implmentation, here with a box/linetemplate. this works great, but when
unmarshalling the collection of templates, castor tries to create an
object of AbstractTemplate instead of the concrete implementation,
following by an exeption of course.
Any ideas for a solution? thanks!!
best regards
martin
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------