-->
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: Changes made to objects get committed without calling save.
PostPosted: Thu Nov 23, 2006 8:49 am 
Newbie

Joined: Thu Nov 23, 2006 8:33 am
Posts: 1
I have a Spring application that uses Hibernate together with JTA. Recently I found out that on the service layer when an Hibernate object was loaded and some parameter changed as a result, the changes later occurred in database although

getHibernateTemplate().saveOrUpdate(myObject);

or any other save method was never called for that object. It came out that all the changes made to objects loaded with Hibernate in service layer directly went to database.

Is there some configuration key that enables to turn of this feature and make the objects state go to database only if save method is explicitly called on the object?

This is the current Hibernate configuration in sessionFactory:

<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.OracleDialect
</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.cache.use_minimal_puts">true</prop>
<prop key="hibernate.hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider
</prop>
<prop key="hibernate.query.factory_class">
org.hibernate.hql.classic.ClassicQueryTranslatorFactory
</prop>
<prop key="hibernate.transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</prop>
<prop key="hibernate.jta.UserTransaction">
java:comp/UserTransaction
</prop>
</props>


Thanx in advance for any tips.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 23, 2006 10:25 am 
Beginner
Beginner

Joined: Fri Oct 06, 2006 7:11 am
Posts: 32
If you make a change to the loaded object in the context of the same transaction Hibernate will automatically update the database.

If the object is a "detached" object, any changes made to it will not be persisted to the Database.

You would need to close the session/transaction and then make changes to your object.


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.