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.  [ 5 posts ] 
Author Message
 Post subject: Updating specific column w/o retrieving entire record
PostPosted: Wed Apr 26, 2006 5:13 am 
Beginner
Beginner

Joined: Thu Apr 20, 2006 3:44 am
Posts: 32
Can any one tell me, whether we can update specific colums(fields) in a table w/o retrieving entire record ?


Top
 Profile  
 
 Post subject: Re: Updating specific column w/o retrieving entire record
PostPosted: Wed Apr 26, 2006 6:15 am 
Beginner
Beginner

Joined: Wed Apr 26, 2006 4:40 am
Posts: 24
sudhirph wrote:
Can any one tell me, whether we can update specific colums(fields) in a table w/o retrieving entire record ?

Only solution I know is to create a class which contains only the columns you want to update.

The easiest and safest way to do it, is to create a SmallClass and a HugeClass which extends SmallClass and create two completely different mappings for them.

This is a little awkward, but the support of explicit polymorphism in Hibernate is currently very limited and sometimes doesn't seem to work at all. (There are no subclasses without a discriminator value, so you have to use some dummy flag hack, and even if you set ploymorphism="explicit" hibernate somtimes loads the subclass if you want to retrieve the base class)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 7:06 am 
Beginner
Beginner

Joined: Thu Apr 20, 2006 3:44 am
Posts: 32
Thomson, assue that I have column c1-c10 in my table.
I am updating only c1-4 and want it to be updated......

Not sure going by your method what value will remaining column, c5-c10 will contain...

I hope you got the point..

Thanks

Sudhir


Top
 Profile  
 
 Post subject: Re: Updating specific column w/o retrieving entire record
PostPosted: Wed Apr 26, 2006 7:53 am 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
sudhirph wrote:
Can any one tell me, whether we can update specific colums(fields) in a table w/o retrieving entire record ?


why don't you use HQL update statement?

http://www.hibernate.org/hib_docs/v3/re ... tch-direct

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 3:17 am 
Beginner
Beginner

Joined: Wed Apr 26, 2006 4:40 am
Posts: 24
sudhirph wrote:
Thomson, assue that I have column c1-c10 in my table.
I am updating only c1-4 and want it to be updated......

Not sure going by your method what value will remaining column, c5-c10 will contain...

I hope you got the point..

Thanks

Sudhir

Hibernate will not touch any columns which are not mapped in your class.

Therefore, if you retreive SmallClass, modify and update it, only the columns mapped in SmallClass will be changed. But don't use SmallClass to insert rows into the DB.


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