-->
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: Hibernate issuing automaic updates
PostPosted: Wed Oct 01, 2008 2:08 pm 
Newbie

Joined: Wed Oct 01, 2008 1:57 pm
Posts: 2
HI All,
I have some persistent and some non persistent fileds in my POJO class.
After reading the data from the database, if i update any non persistent filed in the POJO class the hibernate issuing the update command for that record.It supposed to issue update command when i update only the pursistent filed.

Below is the sample update query issued by the hibernate

update DDDR.TABLE1 set ASSET_NUM=?, ASSET_TYPE_CD=?, ASSET_DOMAIN_CD=?, QUOTE_ID=?, PARTITION_ID=?, CREATE_TS=?, UPDATE_TS=?, STATE_CD=?, POLICY_NUMBER=?, COMP_ID=?, AFFINITY_ACCT_CD=? where ASSET_ID=?


Bacuse of these updates i am getting deadlock exceptions and unable to read the data also.

Thanks in advacne.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 01, 2008 2:20 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
chinnareddy123,

This statement of yours worries me:

Quote:
After reading the data from the database, if i update any non persistent filed in the POJO class the hibernate issuing the update command for that record


I suspect you don't quite understand what the states of a Hibernate object are (persistent / transient /detached), and what is the purpose of the update() method.

Please read my article here

http://hibernar.org/articulos_en/persis ... ethods.php

and then we can discuss.

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 01, 2008 2:38 pm 
Newbie

Joined: Wed Oct 01, 2008 1:57 pm
Posts: 2
Hi ,
Thanks for your reply.

what I mean to say is, i am using some other variables in the POJO class which are not mapped to any of the persistent filed.

What my understanding in this problem is,
when we change any value in the POJO object and use flush() method
the hibernate will issue the update query to that record with the same values.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 01, 2008 3:24 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
Don't worry about hibernate persisting non-mapped fields, that won't happen.

Session.flush() just "levels" the contents of the session, executing whatever SQL statements are necessary so that the database has the same information the session has.
By itself, session.flush() doesn't "generate" any update.

The update() method it is not used "to generate an UPDATE SQL statement". It is used to reconnect a disconnected object back into a session.

_________________
Gonzalo Díaz


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.