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