On Jan 21, 2008 8:49 AM, Bianka Martinovic <[EMAIL PROTECTED]> wrote: > When I look at the load()ed data, all seems fine. But later on, after > > $row->init( %$data ); > > where $data contains something like > > { > 'CMP_NETWORK' => { > 'NICADDRESS' => 'a01010101011' > }, > 'HWLASTSCANDATE' => '2008012114:33:00' > } > > RDBO tries to insert() into the CMP_NETWORK table, just like you guessed. The > question is: Why?
Is NICADDRESS the primary key of whatever class/table the CMP_NETWORK relationship points to? When you set a related object (either using the hashref form { ... } or the object form, it makes no difference) RDBO will save that object if it does not already exist. Also, using init() is the same as making separate methods calls. So this: $row->init ( CMP_NETWORK => { NICADDRESS => 'a01010101011', }, HWLASTSCANDATE => '2008012114:33:00', ); is the same as this: $row->CMP_NETWORK({ NICADDRESS => 'a01010101011' }); $row->HWLASTSCANDATE('2008012114:33:00'); which is also the same as this: $row->CMP_NETWORK(MyCMPNetwork->new(NICADDRESS => 'a01010101011')); $row->HWLASTSCANDATE('2008012114:33:00'); In all cases, when it comes time to save() $row, it sees that it's had its related CMP_NETWORK object set, and it has to decide if it needs to save it as a new row or update an existing row. To do that, it needs to look up the row using a primary or unique key. If none is set, or if no existing row with that key is found, then it does an insert. -John ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object