-->
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.  [ 4 posts ] 
Author Message
 Post subject: cloned connection while in manual transaction mode
PostPosted: Mon May 17, 2004 7:34 am 
Beginner
Beginner

Joined: Mon May 17, 2004 7:15 am
Posts: 24
Hi,

I've been trying to test Hibernate 2.0 with SQL Server. Unfortunatly, the first attempt failed :(. Expect anyone's help.

In short words, I wanna test how to use the inheritance. Two classes were defined: Cat with properties catID, catName and color and DomesticCat extending Cat coming with a new property 'owner'. My test case was to insert a new instance of DomesticCat with the following code:

Session s = sessionFactory.openSession();
Transaction tx = s.beginTransaction();

DomesticCat cat = new DomesticCat();
cat.setCatName("lanlan");
cat.setColor("White");
cat.setOwner("Katie");

s.save(cat);
tx.commit();

But I got errors: "Can't start a cloned connection while in manual transaction mode." (Detailed message will be attached at the end) .

My map file is:



<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class
name="test.entity.Cat"
table="TBL_CAT"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="catID"
column="COL_CAT_ID"
type="java.lang.Long"
>
<generator class="hilo">
</generator>
</id>

<property
name="catName"
type="java.lang.String"
update="true"
insert="true"
column="COL_CAT_NAME"
not-null="true"
/>

<property
name="color"
type="java.lang.String"
update="true"
insert="true"
column="COL_CAT_COLOR"
not-null="false"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Cat.xml
containing the additional properties and place it in your merge dir.
-->

<joined-subclass
name="test.entity.DomesticCat"
table="TBL_D_CAT"
dynamic-update="false"
dynamic-insert="false"
>
<key
column="D_CAT_ID"
/>
<property
name="owner"
type="java.lang.String"
update="true"
insert="true"
column="owner"
/>

</joined-subclass>

</class>

</hibernate-mapping>


And partial error is:

19:08:19,963 DEBUG DriverManagerConnectionProvider:120 - returning connection to pool, pool size: 1
19:08:19,973 DEBUG TableHiLoGenerator:62 - new hi value: 0
19:08:19,983 DEBUG SessionImpl:771 - generated identifier: 1
19:08:20,003 DEBUG SessionImpl:818 - saving [test.entity.DomesticCat#1]
19:08:20,023 DEBUG JDBCTransaction:59 - commit
19:08:20,033 DEBUG SessionImpl:2235 - flushing session
19:08:20,083 DEBUG SessionImpl:2428 - Flushing entities and processing referenced collections
19:08:20,093 DEBUG SessionImpl:2771 - Processing unreferenced collections
19:08:20,103 DEBUG SessionImpl:2785 - Scheduling collection removes/(re)creates/updates
19:08:20,103 DEBUG SessionImpl:2259 - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
19:08:20,103 DEBUG SessionImpl:2264 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
19:08:20,123 DEBUG Printer:75 - listing entities:
19:08:20,123 DEBUG Printer:82 - test.entity.DomesticCat{catName=lanlan, color=White, owner=the fuck ower, catID=1, parent=null}
19:08:20,133 DEBUG SessionImpl:2348 - executing flush
19:08:20,133 DEBUG NormalizedEntityPersister:443 - Inserting entity: [test.entity.DomesticCat#1]
19:08:20,133 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
19:08:20,143 DEBUG SQL:237 - insert into TBL_CAT (COL_CAT_NAME, COL_CAT_COLOR, COL_CAT_ID) values (?, ?, ?)
Hibernate: insert into TBL_CAT (COL_CAT_NAME, COL_CAT_COLOR, COL_CAT_ID) values (?, ?, ?)
19:08:20,153 DEBUG BatcherImpl:241 - preparing statement
19:08:20,153 DEBUG BatcherImpl:196 - about to open: 1 open PreparedStatements, 0 open ResultSets
19:08:20,163 DEBUG SQL:237 - insert into TBL_D_CAT (owner, parentCat, D_CAT_ID) values (?, ?, ?)
Hibernate: insert into TBL_D_CAT (owner, parentCat, D_CAT_ID) values (?, ?, ?)
19:08:20,163 DEBUG BatcherImpl:241 - preparing statement
19:08:20,163 DEBUG JDBCExceptionReporter:36 - SQL Exception

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Can't start a cloned connection while in manual transaction mode.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.getImplConnection(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.setupImplConnection(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.<init>(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.<init>(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.prepareStatement(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.prepareStatement(Unknown Source)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:249)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:61)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:56)
at net.sf.hibernate.persister.NormalizedEntityPersister.insert(NormalizedEntityPersister.java:453)
at net.sf.hibernate.persister.NormalizedEntityPersister.insert(NormalizedEntityPersister.java:433)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2407)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2360)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2229)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 7:37 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Try the jTDS Open Source JDBC driver.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 7:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You need to specify the following parameter to the driver properties:

selectMethod=cursor


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 9:26 am 
Beginner
Beginner

Joined: Mon May 17, 2004 7:15 am
Posts: 24
michael wrote:
You need to specify the following parameter to the driver properties:

selectMethod=cursor


Hi, mate,

Thank you very much.

James


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