-->
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: update composite primary key
PostPosted: Tue Sep 20, 2005 4:56 am 
Newbie

Joined: Tue Sep 20, 2005 4:50 am
Posts: 1
Hi,
The scenario: I have a table with a compostite primary
key, say cloumn X+Y. My query is, how can i update
column Y (i wish to change the primary key but change
only one column) using hibernate 2.1.7

Basic SQL would be, update tableName set Y=? where X=?
and Y=?.

Any light on this please...

Thanks in advance

naren


Top
 Profile  
 
 Post subject: sql
PostPosted: Tue Sep 20, 2005 2:06 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
- HQL is not DML (Data Manipulation Language) therefore it is not possible to have an analogous HQL query;
- All the updates handled by Hibernate after setters get called on objects, but changing object ID is not welcomed by Hibernate therefore I suggest you to evict Object from session and then use SQL to update record in the database. (Note: There is potential conflict with 2nd level cache if you are using it.)

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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.