I have been working with Hibernate only a short period of time. I have gotten my database model up and running and I have generated all the classes using the tools from MyEclipse. I have been successful in storing and retrieving data to the main object/table. I have written a Junit test to accomplish this action. Now I have moved on to the second table. In this table I have one attribute as a LONGTEXT datatype (large XML file). I have mapped this attribute as described in the Hibernate documentation:
Code:
<class name="my.metadata.orm.MetadataDocument" table="metadata_document" catalog="my_metadata_db">
<id name="metadataDocId" type="java.lang.Integer">
<column name="metadata_doc_id" />
<generator class="native" />
</id>
<many-to-one name="myDocument" class="my.metadata.orm.MyDocument" fetch="select">
<column name="fk_jtdi_document_id" not-null="true" />
</many-to-one>
<property name="xmlDocument" update ="true" insert="true" type="java.lang.String" length="2147483647">
<column name="xml_document" />
</property>
<property name="xmFileSize" type="java.lang.Long">
<column name="xm_file_size" />
</property>
<property name="xmlFileName" type="java.lang.String">
<column name="xml_file_name" length="50" />
</property>
<property name="xmlFileCreateDate" type="java.util.Date">
<column name="xml_file_create_date" length="0" />
</property>
<property name="xmlFileUpdateDate" type="java.util.Date">
<column name="xml_file_update_date" length="0" />
</property>
<property name="xmlFileDescription" type="java.lang.String">
<column name="xml_file_description" length="256" />
</property>
<property name="xmlFileOsDate" type="java.util.Date">
<column name="xml_file_os_date" length="0" />
</property>
</class>
What I see in the log files is the data is being pumped into the database as it should. Next, Hibernate fetches the data to test the SELECT statement works. However, something is going wrong because I see:
Code:
Began transaction (1): transaction manager [org.springframework.orm.hibernate3.HibernateTransactionManager@1eeeaed]; default rollback = true
Hibernate:
/*
from
MetadataDocument */ select
metadatado0_.metadata_doc_id as metadata1_154_,
metadatado0_.fk_jtdi_document_id as fk2_154_,
metadatado0_.xml_document as xml3_154_,
metadatado0_.xm_file_size as xm4_154_,
metadatado0_.xml_file_name as xml5_154_,
metadatado0_.xml_file_create_date as xml6_154_,
metadatado0_.xml_file_update_date as xml7_154_,
metadatado0_.xml_file_description as xml8_154_,
metadatado0_.xml_file_os_date as xml9_154_
from
jtdi_metadata_db.metadata_document metadatado0_
- Could not toggle autocommit
com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:888)
at com.mysql.jdbc.Connection.getMutex(Connection.java:3728)
at com.mysql.jdbc.Connection.setAutoCommit(Connection.java:5365)
at org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317)
at org.hibernate.transaction.JDBCTransaction.toggleAutoCommit(JDBCTransaction.java:194)
at org.hibernate.transaction.JDBCTransaction.rollbackAndResetAutoCommit(JDBCTransaction.java:186)
at org.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:162)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doRollback(HibernateTransactionManager.java:597)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:753)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:730)
at org.springframework.test.AbstractTransactionalSpringContextTests.endTransaction(AbstractTransactionalSpringContextTests.java:289)
at org.springframework.test.AbstractTransactionalSpringContextTests.onTearDown(AbstractTransactionalSpringContextTests.java:233)
at org.springframework.test.AbstractSingleSpringContextTests.tearDown(AbstractSingleSpringContextTests.java:125)
at junit.framework.TestCase.runBare(TestCase.java:140)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.access$001(AbstractAnnotationAwareTransactionalTests.java:47)
at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests$1.run(AbstractAnnotationAwareTransactionalTests.java:113)
at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTest(AbstractAnnotationAwareTransactionalTests.java:176)
at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTestTimed(AbstractAnnotationAwareTransactionalTests.java:150)
at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runBare(AbstractAnnotationAwareTransactionalTests.java:109)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
- SQL Error: 0, SQLState: null
- Already closed.
From what I can tell something is happening in the database Connection pool.
My setting are as follows for the database Connection pool:
Code:
<!-- Connection Pool -->
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">1800</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="hibernate.c3p0.acquire_increment">3</property>
<property name="hibernate.c3p0.autoReconnectForPool">true</property>
<property name="hibernate.c3p0.autoReconnect">true</property>
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
Thank you for taking the time to read my post and for any suggestions you can offer.
Russ