Hi--

I'm having a hard time getting lazy loading to work. Mapping, error, and
class files are below. Any general guidelines on how to do it, or specific
advice on my problem would be greatly appreciated!

Thanks


My mapping file:
<class name="A" identity="ID" key-generator="SEQUENCE" access="shared">
                <cache-type type="count-limited" />
                <description>A</description>
                <map-to table="A" xml="A"/>
                <field name="ID" type="integer">
                        <sql name="ID" type="integer"/>
                        <xml node="attribute"/>
                </field>
                <field name="Created" type="date">
                        <sql name="Created" type="timestamp"/>
                        <xml name="Created" node="element"/>
                </field>
                <field name="Updated" type="date">
                        <sql name="Updated" type="timestamp"/>
                        <xml name="Updated" node="element"/>
                </field>
                <field name="Email" type="string">
                        <sql name="Email" type="varchar"/>
                        <xml name="Email" node="element"/>
                </field>
                <field name="T" type="T" lazy="true" collection="vector"
required="false">
                        <sql many-key="AID" />
                        <xml name="Ts" node="element" />
                </field>
        </class>

       <class name="T" identity="ID" key-generator="SEQUENCE"
access="shared">
                <cache-type type="count-limited"/>
                <description>T</description>
                <map-to table="T" xml="Tidbit"/>
                <field name="ID" type="integer">
                        <sql name="ID" type="integer"/>
                        <xml node="attribute"/>
                </field>
                <field name="Created" type="date">
                        <sql name="Created" type="timestamp"/>
                        <xml name="Created" node="element"/>
                </field>
                <field name="Updated" type="date">
                        <sql name="Updated" type="timestamp"/>
                        <xml name="Updated" node="element"/>
                </field>
                <field name="A" type="A">
                        <sql name="VisitorID" />
                        <xml name="Visitor" node="element" />
                </field>
                <field name="CustomField" type="CustomField">
                        <sql name="CustomFieldID" />
                        <xml name="CustomField" node="element" />
                </field>
                <field name="StringValue" Value="string">
                        <sql name="Value" Value="varchar"/>
                        <xml name="Value" node="attribute"/>
                </field>
                <field name="IntValue" Value="integer">
                        <sql name="IntValue" Value="integer"/>
                        <xml name="IntValue" node="attribute"/>
                </field>
        </class>

The error I get:
org.exolab.castor.jdo.DataObjectAccessException: Type conversion error:
could not set value of FieldMolder of A.setT(T Ts) with value of type org.
exolab.castor.persist.RelationCollection


The A Class:
public class A extends PersistentItem {
    private String email = null;
    private Vector ts = new Vector();

    public Visitor() {
        super();
        logger.setPrefix("Visitor");
    }

    public Visitor(String e) {
        setEmail(e);
    }

    public boolean equals(Visitor v) {
        if ( v != null && getEmail().equals(v.getEmail()) ) {
            return true;
        }
        else {
            return false;
        }
    }

    public void setEmail(String e) {
        email = e;
    }

    public void addNewT(String v, CustomField c) {
        T t = new T(v,c);
        for ( Enumeration e = ts.elements(); e.hasMoreElements();  ) {
            t tempt = (t) e.nextElement();
            if ( tempt.getCustomField().equals(t.getCustomField()) ) {
// if we're passing data for an existing t, just update
                tempt.setValue(t.getValue());
                return;
            }
        }
        addt(t);
// if we reach here, then it should be a new t
    }
    public void addt(t t) {
        ts.add(t);
        t.setVisitor(this);
    }
    public boolean addts(Vector v) {
        boolean retval = false;
        for ( Enumeration e = v.elements(); e.hasMoreElements(); ) {
            t t = (t) e.nextElement();
            addNewt(t.getValue(),t.getCustomField());
// so we update ts for this visitor
            retval = true;
        }
        return retval;
    }
    public boolean addts(Collection c) {
        Vector v = new Vector(c);
        return addts(v);
    }
    public void setts(Vector v) {
        ts = v;
    }
    public void setts(Collection c) {
        ts = new Vector(c);
    }

    public String getEmail() {
        return email;
    }

    public Vector getts() {
        return ts;
    }

    public t gettByCustomField(CustomField c) {
        t t = null;
        for ( Enumeration e = ts.elements(); e.hasMoreElements(); ) {
            t t = (t) e.nextElement();
            if ( t.getCustomField().equals(c) ) {
                t = t;
            }
        }
        return t;
    }

}

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

Reply via email to