| 
					
						 I have encountered a problem when updating a String / TEXT field on more than one object in the same session. If one String has been set and then a different String is modified in a new session, I get the following error:
 
 Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@c53dce [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@143c8b3 [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, maxIdleTime -> 3000, maxPoolSize -> 5, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1d2068d [ description -> null, driverClass -> null, factoryClassLocation -> null, jdbcUrl -> jdbc:mysql://127.0.0.1:3306/test, properties -> {user=******, password=******} ] , preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ] , factoryClassLocation -> null, numHelperThreads -> 3, poolOwnerIdentityToken -> c53dce ] 
 Hibernate: insert into data (tx1, tx2, class) values (?, ?, 'test.Data')
 Hibernate: insert into data (tx1, tx2, class) values (?, ?, 'test.Data')
 Hibernate: select data0_.id as id0_, data0_.tx1 as tx3_0_0_, data0_.tx2 as tx4_0_0_ from data data0_ where data0_.id=?
 Hibernate: select data0_.id as id0_, data0_.tx1 as tx3_0_0_, data0_.tx2 as tx4_0_0_ from data data0_ where data0_.id=?
 Hibernate: update data set tx1=?, tx2=? where id=?
 Hibernate: update data set tx1=?, tx2=? where id=?
 org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
 	at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
 	at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
 	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
 	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:181)
 	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
 	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
 	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
 	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
 	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
 	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
 	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
 	at test.Test.update(Test.java:58)
 	at test.Test.main(Test.java:22)
 Caused by: java.sql.BatchUpdateException: Driver can not re-execute prepared statement when a parameter has been changed from a streaming type to an intrinsic data type without calling clearParameters() first.
 	at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:822)
 	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1592)
 	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
 	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
 	... 9 more
 
 This problem has been driving me nuts :-( Ant help would be much appreciated. Sample code and Mapping file that demonstrates the problem below. I am using Hibernate 3.0.5, but this also occurs using Hibernate 2. I am using the 3.1.8 Mysql JDBC driver and MySQL 4.
 
 Regards,
 Greg.
 
 Persistent object
 -----------------
 package test;
 
 public class Data {
 
     protected long id;
     public String tx1;
     public String tx2;
     
     public void setId( long id ) { this.id = id; }   
     public long getId() { return id; }
 }
 
 Test class
 -----------
 package test;
 
 import org.hibernate.Session;
 import org.hibernate.Transaction;
 
 import test.HibernateFactory;
 
 public class Test {
 
     private long id1;
     private long id2;
     /**
      * @param args
      */
     public static void main(String[] args) {
         
         Test t = new Test();
         t.save();
         t.update();
     }
 
     private void save() {
         
         Session session = HibernateFactory.newSession();
         try {
             Transaction tx = session.beginTransaction();
             Data d = new Data();
             d.tx1 = "z"; // If null, no problem 
             session.save(d);
             id1 = d.getId();
 
             Data d2 = new Data();
             session.save(d2);
             id2 = d2.getId();
             
             tx.commit();
         }
         catch(Exception e) {
             e.printStackTrace();
         }
         finally {
             session.close();
         }
     }
     
     private void update() {
         
         Session session = HibernateFactory.newSession();
         try {
             Transaction tx = session.beginTransaction();
             Data data = (Data) session.get(Data.class, new Long(id1));
             Data data2 = (Data) session.get(Data.class, new Long(id2));
             data.tx2 = "x2";
             data2.tx2 = "x2"; // this causes error
             tx.commit();
         }
         catch(Exception e) {
             e.printStackTrace();
         }
         finally {
             session.close();
         }
     }
 } 
 
 Mapping file
 ----------------
 <hibernate-mapping>
 	<class name="test.Data" table="data">
 		<id name="id" column="id" type="long" unsaved-value="0">
 			<generator class="native"/>
 		</id>
 		<discriminator/>
 		<property name="tx1" column="tx1" access="field" not-null="false" type="text" />
 		<property name="tx2" column="tx2" access="field" not-null="false" type="text" />
 		
 	</class>
 </hibernate-mapping> 
					
  
						
					 |