-->
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: Update only after Load?
PostPosted: Sun Nov 02, 2003 1:07 pm 
Newbie

Joined: Thu Oct 23, 2003 11:08 am
Posts: 10
Hi

Maybe a stupid one, but do I have to load a complete object
in order to perform an update on a single field?

I simply want to update a flag field and currently only
succeed by loading the whole object, modifying the
flag and persist the whole thing again...

(of course...I could manage to get the connection and
do it with pure JDBC, but a Hibernate-solution would
be for reasons of portablility, preferable...)

Greetings,
mac


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 02, 2003 4:23 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
How do you think Hibernate will know WHICH property you want to update if you did not load object?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 02, 2003 6:21 pm 
Newbie

Joined: Thu Oct 23, 2003 11:08 am
Posts: 10
...maybe something like the not-null mechanism....
(if fields are null or have a default value are not touched)
...just an idea....
anyway...it would be nice to have a mechanism as it is also
possible with native sql ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 02, 2003 7:44 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
1. Null is valid value for a property and you often need to set and save null value
2. Using a special "default" value has at least two drawbacks - first, you have to specify default value for EVERY property and second - you will not be able to assign and save that default value to a field because from Hibernate's point of view this will mean 'do not save this field, it is unchanged"

I'm afraid there is no way to implement the feature you aking without rewriting just everything. Every object will need to track "dirty" status for every property itself. That means you will either have to code it yourself or use some tricks with runtime class generation. I doubt you want to code it manually :)


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.