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: dynamic-update on class mapping
PostPosted: Tue Nov 08, 2005 4:38 am 
Newbie

Joined: Wed Nov 02, 2005 6:18 am
Posts: 7
I am planning to create a loosly coupled app with web services. I will be adopting the session per request method of working and storing the sessionfactory in HttpApplicationState.Application class so I can create another session from it later

The data is requested via a web service and sent to the client.

I am planning to have a before and after image of the data in the message sent to the client.

The client will manipulate the data and pass it back to the server through another web service.

On the server at this time I then have a) the original data, b) the changed data c) the original time stamp for concurrency

What I want to know is

a) does the dynamic-update = true mapping mean that nhibernate will re-read the row again to see what has changed ?

b) could I pass into a class or method my before and after images so the differences can be detected and the appropriate SQL code generated

c) would I be better off doing this myself and creating the SQL on the fly, thereby just using nhibernate for data retrevial and manually code all updates ?

d) how do I specify an additonal where clause on the update. I will have the Id column as the primary key (that the class already knows about), but where do I put the timestamp value so that is it added to the where clause i.e. UPDATE blah WHERE Id= 1 AND Concurrency = timestamp value

Many thanks

BOb


Top
 Profile  
 
 Post subject: Re: dynamic-update on class mapping
PostPosted: Tue Nov 08, 2005 5:30 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
bobpardoe wrote:
What I want to know is

a) does the dynamic-update = true mapping mean that nhibernate will re-read the row again to see what has changed ?


If you use select-before-update, yes. And select-before-update is almost always less efficient than just updating the row blindly. Otherwise dynamic-update means "update only those fields that you know were changed", and it only works if you're updating the object in the same session it was loaded in.

bobpardoe wrote:
b) could I pass into a class or method my before and after images so the differences can be detected and the appropriate SQL code generated


No, there isn't any such API in NHibernate.

bobpardoe wrote:
c) would I be better off doing this myself and creating the SQL on the fly, thereby just using nhibernate for data retrevial and manually code all updates ?


I think you can do it in NHibernate using SaveOrUpdateCopy - you would reassociate the old object with the session (using Lock), then use SaveOrUpdateCopy(theNewObject) on the session, and commit the transaction later.

bobpardoe wrote:
d) how do I specify an additonal where clause on the update. I will have the Id column as the primary key (that the class already knows about), but where do I put the timestamp value so that is it added to the where clause i.e. UPDATE blah WHERE Id= 1 AND Concurrency = timestamp value


NHibernate does this automatically if you map a property using <version> or <timestamp>.


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.