-->
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: How to insert and update selective columns only?
PostPosted: Thu Apr 13, 2006 4:45 am 
Regular
Regular

Joined: Wed Apr 12, 2006 12:49 am
Posts: 105
Location: Malaysia
Hi,

Sometimes, we just want to update maybe 1 column value instead of 3 columns of a table.

Say the table has name, address, contact.

How should I specify my update statement in mapping file cos sometime I just want to update address, sometimes I just want to update the contact. Meaning depends on the condition, only certain columns should be updated.

How to achieve this? If use <sql-update></sql-update> then we have to fix the update statement. I'm new to hibernate, please advise.

Thank you.

_________________
Thank you.

Regards,
Jap.


Top
 Profile  
 
 Post subject: dynamic-insert=true
PostPosted: Thu Apr 13, 2006 9:56 am 
Senior
Senior

Joined: Tue Mar 09, 2004 2:38 pm
Posts: 141
Location: Lowell, MA USA
In your mapping file set dynamic-insert=true and potentially dynamic-update=true:

http://www.hibernate.org/hib_docs/v3/re ... tion-class

Hibernate will then dynamically generate only and insert or update statement with only the changed properties.

Ryan-

_________________
Ryan J. McDonough
http://damnhandy.com

Please remember to rate!


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.