Hi everyone.

I am trying to obtain an object from the database whos parent class has
already been loaded. Instead of returning an object of the subclass, castor
returns the parent class object. My question is, how do I tell castor to not
do this?

I'm trying to tie castor and  turbine (apache) together, and turbine
requires access to the user objects (for caching etc..) naturally I don't
want to load all the extra verbiage associated with a Contact object.

note: Java class Contact extends User

Here is the code snippet:

            Database db =_store.getDatabase();

            db.begin();
                User u = (User) db.load( User.class, new Integer( 3 ) );
                Contact c = (Contact) db.load( Contact.class, new
Integer(3 ) );
            db.commit();

            _store.returnDatabase( db );

This is what castor tells me:

           "Requested to load/fetch an object of type
nz.co.webrent.om.Contact, where persistent storage returned an object of
type class nz.co.webrent.om.security.User"

This is what I have in the mapping file:

<mapping>
<class name="nz.co.webrent.om.security.User" identity="id">
    <cache-type type="none" />
    <description></description>
    <map-to table="webrent_user" />
        <field name="id" type="integer" required="true">
        <sql name="id" type="integer" />
        <xml name="id" node="attribute" />
    </field>
....
<class name="nz.co.webrent.om.Contact" identity="id"
extends="nz.co.webrent.om.security.User">
    <cache-type type="none" />
    <description></description>
    <map-to table="webrent_contact" />

    <field name="company" type="string">
...

Anyone have any suggestions?

On a related note: how can I tell castor to reload a User object if I have
made changes to a Contact object of the same id? Something along the lines
of  Database.refresh(Class, identity) ?

Eternally grateful (well, till the next reboot anyway)
Bert.






_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to