-->
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 individual columns
PostPosted: Thu Feb 05, 2004 9:41 am 
Newbie

Joined: Thu Feb 05, 2004 9:32 am
Posts: 7
Hello,

I would like to update individual properties of an object, like UPDATE employees SET name='John' for an employee. I can't use 'update=false' attribute for the property as I want my users to choose which property to update. How to do this in Hibernate?

I would really appreciate any comments or ideas.

Best regards,
John


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2004 9:50 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Don't know exactly what you want to do, but...

If you set dynamic-update="true" on your class, only changed properties will be updated at flush. This prevents Hibernate from generating the standard CRUD SQL for that class on startup, it is then generated at runtime.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2004 10:01 am 
Newbie

Joined: Thu Feb 05, 2004 9:32 am
Posts: 7
I have a large table with a lot of columns. Usually I only want to update some of them, but I can't know in advance, which.

I assume that when using 'dynamic-update=true', I would have to update like this:

Code:
session.load(myObject)
myObject.setSomething('value');
session.flush();


The problem is that I can't load the object before updating as it's very big, and contains BLOBS, and therefore would create a lot of uneeded database traffic.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2004 10:04 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
LOBs are lazily loaded, and you can also lazy load all associations. This should be OK, otherwise Hibernate (and almost all other O/R mapping tools) is not the right tool for this use case. You can get a JDBC connection from the Session if you need it.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2004 10:13 am 
Newbie

Joined: Thu Feb 05, 2004 9:32 am
Posts: 7
Thanks ;)


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.