Peter,
What about just extending normalally in your java classes and treating them
as two completely different classes in your mapping file? You'd still be
able to take advantage of polymorphism in your coded logic.

That is to say, completely map all fields of both classes. It would be nice
to factor out the parent field mapping from the child, but if it's a problem
you need to resolve fast...

-richard


-----Original Message-----
From: Jeszenszky Peter [mailto:[EMAIL PROTECTED]
Sent: August 11, 2003 9:52 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] Extends problem


Hello,

Consider a Foo class whose instances contain a vector of dependent Bar
objects. The foo SQL table stores the Foo objects and the bar table the
dependent Bar objects.

Also consider a FooWithoutBars class that is mapped to the foo
table and contains all fields of the Foo class except the vector of
dependent
objects.

I would like to implement the Foo class using extension, it should extend
the
FooWithoutBars:

        public class Foo extends FooWithoutBars {

                Vector  bars = new Vector();

                public void setBars(Vector _bars) {
                        bar = _bars;
                }

                public Vector getBars() {
                        return bars;
                }
        }

How the corresponding <class> element should like in the mapping file?

I have tried

        <class name="Foo" extends="FooWithoutBars">

                <cache-type type="none"/>

                <field name="bars" type="Bar" collection="vector">
                        <sql many-key="foo_id"/>
                </field>

        </class>

However that results in an exception (No mapping found for the class
Foo). Why do I have to specify a <map-to> element if the class extends
the base class just with a vector of dependent objects? Any idea how to
workaround this problem?

Best regards,

Peter

-----------------------------------------------------------
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

Reply via email to