-->
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 (only changed columns) does not seem to work
PostPosted: Tue Jun 21, 2005 5:38 pm 
Newbie

Joined: Tue Jun 21, 2005 5:15 pm
Posts: 1
I cannot get dynamic updates to work. I can see that caching is enabled (and seems to work for my selects), however when I just change one column, the sql generated is for all columns. In my JUnit test, I read an object, make a simple change to one column, then update it (note the read and update are in successive EJB calls) I have searched the documentation and FAQ, but must be missing something. My persistence layer is behind a stateless session bean. Thank you!

Hibernate version:
3.0.2
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="com.tomax.uid">

<class name="UserroleHdrCBO" table="USERROLE_HDR" dynamic-update="true" >
<cache usage="read-write"/>
<id name="rolename" column="ROLENAME" type="java.lang.String">
<generator class="assigned"/>
</id>
<property name="rolename" column="ROLENAME" type="java.lang.String" insert="false" update="false" />
<property name="description" column="DESCRIPTION" type="java.lang.String" />
<property name="effectiveDt" column="EFFECTIVE_DT" type="java.util.Date" />
<property name="expireDt" column="EXPIRE_DT" type="java.util.Date" />
</class>
</hibernate-mapping>


<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.connection.datasource">java:TomaxDS</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="hibernate.cache.use_minimal_puts">true</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.transaction.auto_close_session">true</property>
<property name="hibernate.transaction.flush_before_completion">true</property>

<property name="show_sql">true</property>

<mapping resource="com/tomax/uid/UserroleHdr.hbm.xml" />
</session-factory>
</hibernate-configuration>


Code between sessionFactory.openSession() and session.close():
Retrieval code:
Session session = HibernatePersistFactory.getSessionFactory().getCurrentSession();
Criteria crit = session.createCriteria(obj.getClass());
Example exmp = Example.create(obj);
crit.setCacheable(true);
crit.add(exmp);
return crit.list();


update code:
session = HibernatePersistFactory.getSessionFactory().getCurrentSession();
session.update(obj);

Full stack trace of any exception that occurs:
(no stack trace)
Name and version of the database you are using:
Oacle 9i
The generated SQL (show_sql=true):

15:06:09,969 INFO [STDOUT] Hibernate: update USERROLE_HDR set DESCRIPTION=?, EF
FECTIVE_DT=?, EXPIRE_DT=? where ROLENAME=?


Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 21, 2005 10:37 pm 
Regular
Regular

Joined: Thu Apr 21, 2005 9:05 am
Posts: 50
Location: Boston, U.S
Your configuration file seems to be ok.

The update on columns happens only when you reset the values
on the object for example....

Employee emp = session.load(new integer("1001");
emp.setName("xxxx");
emp.setSex("xxxx");
session.save(emp);

In the above example, hibernate will update only Name and Sex
columns.


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.