I have a simple class ProcessInstance which maps to procinstance table. I'm using code below to update status field. The problem I have is, the new status didn't get updated in the db out of every several calls to the java code. I enabled show_sql and was able to see if the sql is generated or not.
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0.5
Mapping documents:
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="connection.url">jdbc:mysql://10.10.1.14/xxx</property>
<property name="connection.username">xxx</property>
<property name="connection.password">xxx</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<!--property name="hbm2ddl.auto">create</property-->
<mapping resource="com/danucom/mforms/data/ProcessInstance.hbm.xml"/>
</session-factory>
</hibernate-configuration>
<?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.danucom.mforms.data">
<class name="ProcessInstance" table="procinstance">
<comment>A process instance</comment>
<id name="id">
<generator class="native"/>
</id>
<property name="data"/>
<property name="status"/>
<property name="mboxId" column="mboxid"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
s.setCacheMode(CacheMode.REFRESH);
s.setFlushMode(FlushMode.ALWAYS);
Transaction tx = null;
tx = session.beginTransaction();
ProcessInstance procInstance = (ProcessInstance) session.load(ProcessInstance.class, new Long(procInstanceId));
procInstance.setStatus(newStatus);
session.save(procInstance);
tx.commit();
Full stack trace of any exception that occurs: NONE
Name and version of the database you are using:
MySQL 4.0.25 and mysql-connector-java-3.0.15-ga
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: