-->
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.  [ 4 posts ] 
Author Message
 Post subject: How to do this action by Hibernate world?
PostPosted: Fri Jan 02, 2004 7:32 am 
Newbie

Joined: Mon Sep 08, 2003 12:51 am
Posts: 19
Dear all,

I wonder how to perform this sql by hibernate.

SQL: update person set status = 1 where name='Jack' and status = 0

Best regards,

Jun Huang


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 02, 2004 7:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Query the objects you want to manipulate using session.find() and then change the property you want to change. Or use a standard SQL query by obtaining the Database Connection by session.getConnection()


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 02, 2004 9:53 am 
Newbie

Joined: Mon Sep 08, 2003 12:51 am
Posts: 19
Thanks, gloeglm

The real thing I want to do is to prevent two processes from modifying the same record at the same moment.

I think the hardcode SQL could achieve my aim could but can session.find perform query and update actions in one sql call?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 02, 2004 10:16 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Have a look at the optimistic locking and version tag. Hibernate does that for you.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.