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 Write Update Query In Hibernate?
PostPosted: Mon Apr 23, 2007 2:37 am 
Beginner
Beginner

Joined: Thu Apr 12, 2007 12:04 pm
Posts: 25
Location: Chennai
Hi Everyone.

Greetings!

Could anyone tell that how should i write Update query in hibernate without using HQL query.. I mean i want to use Criteria Query since i have used only Criteria in my whole project. And my project leader also wants me to use that only.

Kindly Give me an example code for follwing query.

update Login(tablename) set password(fieldname1) = 'abc' where username(fieldname2) = '001';

I will be really greatful to u all if u reply me soon.

Thanks alot in advanced.

With Regards

Saurav Jain

_________________
I Really want to share my knowledge and learn from you all people specaily about Hibernate.. Thanks Lot


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 23, 2007 6:22 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
HI intimate2talent,

With in the transaction scope if you change any value of persistent object that would reflect to DB with update statement.

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject: Hi,Thanks For Ur Answer..
PostPosted: Mon Apr 23, 2007 6:34 am 
Beginner
Beginner

Joined: Thu Apr 12, 2007 12:04 pm
Posts: 25
Location: Chennai
Hi dear,
Thats correct, But it updats the value based on Primary Key only. i want to know if i dont give Primary Key then how to update it..

Thanks
With regards
Saurav Jain

_________________
I Really want to share my knowledge and learn from you all people specaily about Hibernate.. Thanks Lot


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 23, 2007 6:50 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi Saurav ,

With out HQl you can do by native SQL. session.CreateSQLQuery().Or Try to Execute Store Proc by session.connection() .But both of them not recommended in Hibernate

_________________
Dharmendra Pandey


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.