-->
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.  [ 5 posts ] 
Author Message
 Post subject: Error occurs in SQL when updating TEXT fields with MYSQL
PostPosted: Tue Jun 14, 2005 6:54 am 
Newbie

Joined: Tue Jun 14, 2005 6:41 am
Posts: 3
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>


Top
 Profile  
 
 Post subject: hibernate.properties
PostPosted: Thu Oct 06, 2005 7:40 am 
Newbie

Joined: Thu Oct 06, 2005 7:20 am
Posts: 2
Location: Semarang, Indonesia
How about changing hibernate.properties so that it contains:
Code:
hibernate.jdbc.use_streams_for_binary false


Top
 Profile  
 
 Post subject: Still get a problem.
PostPosted: Thu Oct 06, 2005 9:52 am 
Newbie

Joined: Tue Jun 14, 2005 6:41 am
Posts: 3
Thanks for your reply. I tried setting : hibernate.jdbc.use_streams_for_binary=false

but got the following error. I think this is due to the being set to null first, and then to a text value.

Any further help would be most appreciated.

Greg.

[ERROR] 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.
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 stingray.test.TextFieldTest.update(TextFieldTest.java:57)
at stingray.test.TextFieldTest.main(TextFieldTest.java:20)
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:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 18, 2005 1:11 pm 
Newbie

Joined: Fri Nov 18, 2005 1:09 pm
Posts: 1
Any luck with solving this one - I'm seeing the same thing.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 18, 2005 1:28 pm 
Newbie

Joined: Tue Jun 14, 2005 6:41 am
Posts: 3
No, afraid not. I resorted to using JDBC for the object I was having a problem with, getting the connection from the Session object.

I was fortunate in that the object I was having a problem with did not have any complex relationships.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.