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: Hibernate saving things it shouldn't :[
PostPosted: Fri Feb 16, 2007 3:35 pm 
Beginner
Beginner

Joined: Wed Apr 05, 2006 8:16 pm
Posts: 20
Hi,

We are using hibernate on a project I am working on and I can't figure out why it is saving certain data.

We have an Issue object, and each Issue has one associated ProfileVersion. This ProfileVersionshould *not* ever be saved by Hibernate. While we do need to save the Issue, all we ever need to do is read the ProfileVersion -- Never save it or update the ProfileVersion through Hibernate. What is the best way to ensure this? I have our configuration for the Issue object saying:

<many-to-one name="profileVersion" class="com.fifththird.cit.model.ProfileVersion"
fetch="select" cascade="none">


But still I see in the logs where hibernate is trying update statements on the ProfileVersion table, and this is busting our code. Thanks in advance if anyone can help, or just for taking the time to read my post! :],

Jim


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 16, 2007 3:51 pm 
Regular
Regular

Joined: Sun Sep 17, 2006 2:48 am
Posts: 81
Location: California
Can you verify if any data in the ProfileVersion object is getting dirty before the commit is executed? If it is, then hibernate will certainly try to flush those changes using update.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 16, 2007 5:35 pm 
Beginner
Beginner

Joined: Wed Apr 05, 2006 8:16 pm
Posts: 20
Thanks for the feedback on this question! How can I tell if an object is dirty? I see an isDirty() method on the Hibernate session, but can I tell if individual objects are dirty? Thanks again,

Jim


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 16, 2007 5:54 pm 
Regular
Regular

Joined: Sun Sep 17, 2006 2:48 am
Posts: 81
Location: California
I was also looking for isDirty at object level, but I couldnt locate. I will search more to find out that answer. Till that time, look into the hibernate logs. That would certainly tell you that for this class which fields have been detected by hibernate as dirty and with what values. Then you will have to debug your code/look into the code to see where it is happenning.
This is the easiest way that I know and which I use.

Hope that helps.
Thanks


Top
 Profile  
 
 Post subject: Thanks!
PostPosted: Fri Feb 16, 2007 5:58 pm 
Beginner
Beginner

Joined: Wed Apr 05, 2006 8:16 pm
Posts: 20
Thanks for the help -- I'll look into that approach,

Jim


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.