Hello David. Yes, this is all set correctly.
I have traced into the code, and as I explained, the problem really seems to be related to Criteria and BasePeer's doInsert(), not to other flags and settings like "new", "modified", "idmethod", etc... Thank for your support, -- Mathieu -----Original Message----- From: David Wynter [mailto:[EMAIL PROTECTED]] Sent: February 14, 2002 12:02 PM To: Turbine Users List; [EMAIL PROTECTED] Subject: RE: Does anyone got IDBroker to work with .save()? Are you using obj.setModified(false); obj.setNew(true); Before calling obj.save(); ? Similarly use obj.setModified(true); obj.setNew(false); when updating a OM object that already exists. -----Original Message----- From: Mathieu Frenette [mailto:[EMAIL PROTECTED]] Sent: 14 February 2002 13:24 To: 'Turbine Users List' Subject: Does anyone got IDBroker to work with .save()? Hello! When I create a new OM object with a non-specified (null) PK and save it to the DB, the IDBroker doesn't get invoked. For example, the following: MyObj obj = new MyObj(null, "John", "Smith"); obj.save(); Would result in the following row being inserted: null, "John", "Smith" Even if my IDBroker and ID_TABLE are correctly configured. I traced into the Peer code and understood why, but I can't see how to get it to work without modifying Torque's source code. Here are my findings: The object's save() method calls the Peer's doInsert(), which in turn calls buildCriteria(). buildCriteria() creates a criterion for *every* column of the table, *including* the PK, even if this PK is null! However, since my OM object doesn't have a PK (obviously it is null at this point in time), a criterion for "PK=null" is added to Criteria. Then, finally, when Torque needs to determine whether or not to use the IDBroker, it checks to see if the PK is specified in the Criteria, which is the case (but it doesn't check to see whether the *value* of the criteria is null, only if it is present). So it decides not to use the IDBroker. I simply cannot understand how the IDBroker can be used, other than by using it manually. The automatic behavior could never be called, at least not when calling .save() or .doInsert() for a new OM object, which always have a null PK. I couldn't find any documentation regarding ID generation, so any help would be greatly appreciated... Best regards, Mathieu Frenette Software Architect Freeborders Canada inc. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
