These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Is it possible to add criteria to an update?
PostPosted: Tue Nov 08, 2005 9:58 am 
Newbie

Joined: Wed Nov 02, 2005 6:18 am
Posts: 7
I've spent some time investigating the use of <timestamp> in the mapping file which doesn't appear to work because NHibernate uses the DateTime type to map to the TimeStamp field. This then causes errors when attempting to update the data. I've tried using DateTime, Int32 and Byte[] for the property but none of these work (I get casting errors). I've looked at the documentation and these forums and can find no solution to this problem.

As an alternative I'm reading the timestamp value in via a <property> and trying to add a condition on the update (using CreateCriteria) so that it would appear something like

Code:
UPDATE table
SET x = y
WHERE id = <id>
and timestamp = <original timestamp>


Hopefully this would then only do the update if the original timestamp value has not changed. However doing a trace on the resulting SQL I can see that the timestamp line never gets added. Does this mean the CreateCriteria method only works on data retrievals and not updates? Is there any way of doing this at all or does it not fit in with the methodology?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 08, 2005 10:51 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
IMO, you should find out why your <timestamp> doesn't work...
Can you give more details about the errors you get?

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.