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:
|