Hi Geir,
sorry, but you can't use nested attributes in Castor with interfaces.
The return/parameter types should be concrete classes having
constructor without parameters.
Oleg
Geir Ove Gr�nmo wrote:
> Hi all!
> I've just started using Castor, but I've stumbled into a challenge wrt
> the mapping file that I can't figure out to solve.
> The Topic class has an attribute called subject that is an instance
> implementing the LocatorIF interface. The TM_TOPIC table to which the
> Topic class maps has two columns containing the LocatorIF data
> (subject_notation and subject_address).
> From reading the documentation I see that nested attibutes can be
> used. The problem is that it seems to me like Castor uses introspection
> it figure out the type of the subject attribute. In this case it is an
> interface, not a concrete type.
> My question is how can it figure out that it is to instantiate an object
> of the SubjectLocator class? Can this be specified somewhere? Or are
> there another technique I can use to map this object?
> (I've used TopLink earlier and the subject attribute was then mapped to
> an aggregate object.)
> All the best,
> Geir O.
> PS. Note that the Topic.getSubject method should return null if the
> subject locator isn't specified, so I cannot cheat by having it return
> an empty subject locator of the correct type.
> -------------------------------------------------------------------
> Classes:
> public class Topic {
> protected LocatorIF subject;
> public LocatorIF getSubject();
> public void setSubject(LocatorIF);
> ...
> }
> public class SubjectLocator implements LocatorIF {
> protected String notation;
> protected String address;
> public String getNotation();
> public String getAddress();
> }
> -------------------------------------------------------------------
> Database schema:
> create table TM_TOPIC (
> id int not null,
> subject_notation varchar(12),
> subject_address varchar(255),
> ...
> );
> -------------------------------------------------------------------
> Castor mapping:
> <class name="Topic" identity="id">
> <map-to table="TM_TOPIC"/>
> <field name="id" type="integer" >
> <sql name="id" type="integer"/>
> </field>
> <!-- SubjectLocator -->
> <field name="subject.notation">
> <sql name="subject_notation"/>
> </field>
> <field name="subject.address">
> <sql name="subject_address"/>
> </field>
> ...
> </class>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev