cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Lewis <>
Subject writeProperty() no longer useful for relationships
Date Thu, 27 Apr 2006 23:31:45 GMT
Another little surprise we encountered with 1.2B2... dunno if it's a bug
or only a documentation correction or neither.  I had some code that
used CayenneDataObject.writeProperty() to write a new object's
attributes and to-one relationships.  It made it easy to copy the values
from a Map with keys named the same as the properties.

This worked fine until now, and the javadocs say "This method can safely
be used instead of or in addition to the auto-generated property
modifiers in subclasses of CayenneDataObject."  But now if I set a
*relationship* with writeProperty() , the  foreign key  is left null in
the generated SQL.

    Before commit, object = {<ObjectId:WebSlowpay, TEMP:...>; new
    [companyContact=>{<ObjectId:CompanyContact, CONTACT_NIC_ID=109572>}
    ... That's a to-one relationship on the key Contact_Nic_ID.  Rest of
properties omitted...

    The SQL is:

    [batch bind: NULL, ...]   -- should be 109572
    *** error. java.sql.SQLException: ORA-01400: cannot insert NULL ...

It works fine if I change it to use the normal setter method
setCompanyContact() or the equivalent setToOneTarget().

View raw message