db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Gordon <rgor...@mwt.net>
Subject Re: save/update problem
Date Fri, 20 Feb 2004 08:38:37 GMT

You know, it is really amazing how just asking the question can often
lead to an answer. It turns out I did not have any key defined for
the table I was trying to update.  Therefore, no selection
criterion were added to the 'selectCriteria' object  way down
in BaseMyObjPeer.doUpdate.

When I added a key to the table and generated new OM classes,
lo and behold, a new line showed up in BaseMyObjPeer that looked
like this:

selectCriteria.put(BIB_NUMBER, criteria.remove(BIB_NUMBER));

thereby providing a non-null keySet() further down in BasePeer.doUpdate.

Isn't life strange?

Rob

ps. I would not be surprised if some of those other save/update problems
people have been posting for the last few years were also caused by not
definng a key for a table.


Rob Gordon wrote:

> I am trying to do an update (ie, a save) on a Torque OM object.
> I fetched the object in a previous select, change two fields
> and now want to update the underlying record. Per everything
> I read all I have to do is call save. Nothing is happening.
>
> I am using 3.1.
>
> I have noticed many questions on the archive on problems
> involving update, but not many good answers. So, I offer
> another question.
>
> When I get way down in:
>
> BaseMyObjPeer.doUpdate(criteria, con)
>
> there is a call made to construct a new Criteria object, the
> selectCriteria,  which--without futher manipulation--passed to
>
> BasePeer.doUpdate(selectCriteria, criteria, con)
>
> Within BasePeer, a  keySet() of the selectCriteria's hash entries
> is requested BUT this in null--nothing was every done to selectCriteria
> except construct. It makes perfect sense that it is null, however, being
> so all the meaningful code within BasePeer.doUpdate() is skipped
> and the update never takes place. The updated record is not written
> to database.
>
> What the heck is going on? How does this ever work if nothing
> is ever added to the selectCriteria object so that requesting
> a keySet does not return null?
>
> Rob
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message