-->
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.  [ 3 posts ] 
Author Message
 Post subject: Questions to the Session.merge() function
PostPosted: Mon Aug 22, 2005 11:11 am 
Newbie

Joined: Mon Aug 22, 2005 10:50 am
Posts: 1
Hibernate version: 2.1

We are currently designing a web-based application which shall use Hibernate for ORM

In our App we create Instances of Objects (let's say a Student named Patrik with several attributes) and pass the Instance to a DTO-Factory which creates a XML-File representing the Student. (Session closed, Instance is detached or even destroyed).

The XML-File is sent to a Client where it will be modified. The Client then sends back a XML-File containing (in the worst case) only an Identifier and one attribute (e.g. the phone Number) which has been changed.

The XML-File ist then processed by the DTO-Factory which instanciates an Instance of Student that has only the Identifier and Phone Number set to proper values (the Rest is asumed to be NULL).

Now, what happens exactly, when the merge() function is called with the (crippeled) Student Instance. (New Session)

Is the function intelligent enough to copy only the phone Number into the Database, or will the rest of the attributes of the Student be set to NULL, or will happen some other strange effects?

The main question behind this scenario is:
Do we need to keep the Instance of the Student in a (e.g. http-) Session and implement our on Version of a merge() which applies the changes made in the XML-File to this instance (and than use SaveOrUpdate() ), or is Hibernate able to handle this by the build-in merge()-function?

Any help appreciated!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 22, 2005 11:23 am 
Newbie

Joined: Tue Aug 02, 2005 1:40 pm
Posts: 16
Location: US
I am not sure weather this is what you are looking for. But when your changes comes back from the client. You may just load the Student befor the update. then set the changed values and I belive changes would be saved accordingly.

Frankly I never tried this but logically it looks like it should work this way.

But then y does the client not want to send the entire XML back with changes and rather decides to send only one parameter value??


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 12:30 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi

I have used merge() it sets NULL to other values in the table.

SO i have used the HQL update for specific column. If you know that the column is specific you can use HQL. Look in to the below link for an example.
http://www.hibernate.org/hib_docs/v3/re ... tch-direct

If it varies on the runtime then you can load the Object with save() and then use update() or saveorupdate() to update the value.

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.