-->
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.  [ 2 posts ] 
Author Message
 Post subject: Strangeness with hbm2ddl.auto property
PostPosted: Tue Feb 07, 2006 11:43 am 
Newbie

Joined: Mon Feb 06, 2006 5:24 pm
Posts: 4
I am seeing some strange behavior using the hbm2ddl.auto property
when set to update. I haven't seen anyone else with the same problem,
so it is probably something I am doing.

I have a simple mapping file named Junk (XML below). In my configuration file, I have set the hbm2ddl.auto to be update. When I do this, I get an exception when I try to begin a transaction stating that:
java.sql.SQLException: com.mchange.v2.c3p0.PoolBackedDataSource@edf3f6 [...] has been closed() -- you can no longer use it.

Now, if I change the hbm2ddl.auto value to be create or create-drop everything works fine in my test. I have included the pertinent test code,
mapping and hibernate.cfg.xml code below. When I look at the logs
I don't see anything too different. Note, that in the case of update, Hibernate is definitely talking to the database when it is starting up,
it just throws the Exception when I try to open a transaction

I have isolated the problem down to a test case, which is copied in below.


Hibernate version: 3.1.2

Mapping documents:

<hibernate-mapping>
<class name="Junk" table="junk">

<id name="id" column="junkId" unsaved-value="-1">
<generator class="native">
<param name="sequence">junkIdSeq</param>
</generator>
</id>
<property name="junk"/>
</class>
</hibernate-mapping>

Configuration File:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>

<property name="connection.url">jdbc:postgresql://localhost/noodle</property>
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.username">blank</property>
<property name="connection.password">blank</property>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>

<property name="show_sql">true</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hbm2ddl.auto">create</property>
<property name="hibernate.current_session_context_class">thread</property>
<!-- Connection pooling -->
<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>

<!-- Mapping files -->
<mapping resource="Junk.hbm.xml"/>
</session-factory>

</hibernate-configuration>

Code between sessionFactory.openSession() and session.close():

Session session = sessionFactory.getCurrentSession();
Transaction tx = session.beginTransaction();
Junk junk = new Junk("This is a test string");
session.save(junk);
tx.commit();
assertTrue("junk.getId() is not set", junk.getId().longValue() != -1);

Full stack trace of any exception that occurs:
java.sql.SQLException: com.mchange.v2.c3p0.PoolBackedDataSource@edf3f6 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@1fe1feb [ 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, identityToken -> 1fe1feb, idleConnectionTestPeriod -> 0, initialPoolSize -> 5, maxIdleTime -> 1800, maxPoolSize -> 20, maxStatements -> 50, maxStatementsPerConnection -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1632847 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1632847, jdbcUrl -> jdbc:postgresql://localhost/noodle, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -> edf3f6, numHelperThreads -> 3 ] has been closed() -- you can no longer use it.
at com.mchange.v2.c3p0.PoolBackedDataSource.assertCpds(PoolBackedDataSource.java:234)
at com.mchange.v2.c3p0.PoolBackedDataSource.getPoolManager(PoolBackedDataSource.java:246)
at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:94)
at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:35)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:360)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:122)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:125)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1309)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
at $Proxy0.beginTransaction(Unknown Source)
at HibernateTest.test(HibernateTest.java:74)
... [Test Harness methods]

Name and version of the database you are using:

PostgreSQL 8.1.1


Debug level Hibernate log excerpt:

0 INFO cfg.Environment - Hibernate 3.1.2
15 INFO cfg.Environment - hibernate.properties not found
15 INFO cfg.Environment - using CGLIB reflection optimizer
15 INFO cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
93 INFO cfg.Configuration - configuring from resource: /hibernate.cfg.xml
93 INFO cfg.Configuration - Configuration resource: /hibernate.cfg.xml
406 DEBUG util.DTDEntityResolver - trying to locate http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath under org/hibernate/
406 DEBUG util.DTDEntityResolver - found http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath
453 DEBUG cfg.Configuration - connection.url=jdbc:postgresql://localhost/noodle
453 DEBUG cfg.Configuration - connection.driver_class=org.postgresql.Driver
453 DEBUG cfg.Configuration - connection.username=postgres
453 DEBUG cfg.Configuration - connection.password=postgres
468 DEBUG cfg.Configuration - dialect=org.hibernate.dialect.PostgreSQLDialect
468 DEBUG cfg.Configuration - show_sql=true
468 DEBUG cfg.Configuration - transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory
468 DEBUG cfg.Configuration - hbm2ddl.auto=update
468 DEBUG cfg.Configuration - hibernate.current_session_context_class=thread
484 DEBUG cfg.Configuration - hibernate.c3p0.min_size=5
484 DEBUG cfg.Configuration - hibernate.c3p0.max_size=20
484 DEBUG cfg.Configuration - hibernate.c3p0.timeout=1800
484 DEBUG cfg.Configuration - hibernate.c3p0.max_statements=50
484 DEBUG cfg.Configuration - null<-org.dom4j.tree.DefaultAttribute@30d082 [Attribute: name resource value "Junk.hbm.xml"]
500 INFO cfg.Configuration - Reading mappings from resource: Junk.hbm.xml
500 DEBUG util.DTDEntityResolver - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
500 DEBUG util.DTDEntityResolver - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
656 INFO cfg.HbmBinder - Mapping class: Junk -> junk
687 DEBUG cfg.HbmBinder - Mapped property: id -> junkId
687 DEBUG cfg.HbmBinder - Mapped property: junk -> junk
687 INFO cfg.Configuration - Configured SessionFactory: null
687 DEBUG cfg.Configuration - properties: {java.vendor=Sun Microsystems Inc., show_sql=true, hibernate.connection.url=jdbc:postgresql://localhost/noodle, os.name=Windows XP, hbm2ddl.auto=update, sun.boot.class.path=C:\j2sdk1.4.2_05\jre\lib\rt.jar;C:\j2sdk1.4.2_05\jre\lib\i18n.jar;C:\j2sdk1.4.2_05\jre\lib\sunrsasign.jar;C:\j2sdk1.4.2_05\jre\lib\jsse.jar;C:\j2sdk1.4.2_05\jre\lib\jce.jar;C:\j2sdk1.4.2_05\jre\lib\charsets.jar;C:\j2sdk1.4.2_05\jre\classes, hibernate.current_session_context_class=thread, hibernate.c3p0.max_size=20, sun.java2d.fontpath=, java.vm.specification.vendor=Sun Microsystems Inc., java.runtime.version=1.4.2_05-b04, hibernate.c3p0.min_size=5, user.name=gsingers, connection.driver_class=org.postgresql.Driver, idea.launcher.bin.path=C:\Program Files\JetBrains\IntelliJ IDEA 5.0\bin, hibernate.c3p0.timeout=1800, user.language=en, sun.boot.library.path=C:\j2sdk1.4.2_05\jre\bin, dialect=org.hibernate.dialect.PostgreSQLDialect, java.version=1.4.2_05, user.timezone=, sun.arch.data.model=32, java.endorsed.dirs=C:\j2sdk1.4.2_05\jre\lib\endorsed, sun.cpu.isalist=pentium i486 i386, file.encoding.pkg=sun.io, file.separator=\, java.specification.name=Java Platform API Specification, hibernate.cglib.use_reflection_optimizer=true, java.class.version=48.0, user.country=US, connection.url=jdbc:postgresql://localhost/noodle, java.home=C:\j2sdk1.4.2_05\jre, java.vm.info=mixed mode, os.version=5.1, transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory, hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory, path.separator=;, connection.password=postgres, java.vm.version=1.4.2_05-b04, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, hibernate.connection.password=postgres, user.variant=, java.awt.printerjob=sun.awt.windows.WPrinterJob, sun.io.unicode.encoding=UnicodeLittle, awt.toolkit=sun.awt.windows.WToolkit, hibernate.connection.username=postgres, user.home=C:\Documents and Settings\gsingers, java.specification.vendor=Sun Microsystems Inc., hibernate.hbm2ddl.auto=update, java.library.path=C:\j2sdk1.4.2_05\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\Perl\bin\;C:\Python23\.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Adaptec Shared\System;C:\WINDOWS\system32\nls;C:\WINDOWS\system32\nls\ENGLISH;C:\PROGRA~1\ULTRAE~1;C:\PROGRA~1\Tcl\bin;c:\ANT\bin;C:\j2sdk1.4.2_05\bin;c:\ENG\bin;C:\Program Files\GNU\WinCvs 1.2;c:\python23;C:\mysql\bin;C:\ENG\eQuery\TextTagger\bin;C:\Program Files\Apache Software Foundation\Maven 1.1-beta-2\bin;C:\Program Files\Subversion\bin;C:\Program Files\Common Files\GTK\2.0\bin;C:\Program Files\PostgreSQL\8.1\bin;c:\cygwin\bin;C:\Program Files\QuickTime\QTSystem\;C:\Sun\jwsdp-1.5\jwsdp-shared\bin, java.vendor.url=http://java.sun.com/, hibernate.connection.driver_class=org.postgresql.Driver, connection.username=postgres, java.vm.vendor=Sun Microsystems Inc., hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, java.class.path=C:\ENG\Noodles\target\classes;C:\Documents and Settings\gsingers\.maven\repository\commons-collections\jars\commons-collections-2.1.1.jar;C:\Documents and Settings\gsingers\.maven\repository\xerces\jars\xercesImpl-2.6.2.jar;C:\Documents and Settings\gsingers\.maven\repository\xml-apis\jars\xml-apis-1.0.b2.jar;C:\Documents and Settings\gsingers\.maven\repository\xalan\jars\xalan-2.7.0.jar;C:\Documents and Settings\gsingers\.maven\repository\hibernate\jars\hibernate-3.1.2.jar;C:\Documents and Settings\gsingers\.maven\repository\antlr\jars\antlr-2.7.6rc1.jar;C:\Documents and Settings\gsingers\.maven\repository\cglib\jars\cglib-2.1.3.jar;C:\Documents and Settings\gsingers\.maven\repository\dom4j\jars\dom4j-1.6.1.jar;C:\Documents and Settings\gsingers\.maven\repository\ehcache\jars\ehcache-1.1.jar;C:\Documents and Settings\gsingers\.maven\repository\jta\jars\jta-UNKNOWN.jar;C:\Documents and Settings\gsingers\.maven\repository\asm\jars\asm-1.5.3.jar;C:\Documents and Settings\gsingers\.maven\repository\jdbc\jars\jdbc2_0-stdext.jar;C:\Documents and Settings\gsingers\.maven\repository\asm\jars\asm-attrs-1.5.3.jar;C:\Documents and Settings\gsingers\.maven\repository\c3p0\jars\c3p0-0.9.0.jar;C:\Documents and Settings\gsingers\.maven\repository\postgresql\jars\postgresql-8.1-404.jdbc3.jar;C:\Documents and Settings\gsingers\.maven\repository\commons-logging\jars\commons-logging-1.0.4.jar;C:\Documents and Settings\gsingers\.maven\repository\commons-beanutils\jars\commons-beanutils-1.7-dev.jar;C:\Documents and Settings\gsingers\.maven\repository\hsqldb\jars\hsqldb-1.7.3.3.jar;C:\Documents and Settings\gsingers\.maven\repository\log4j\jars\log4j-1.2.8.jar;C:\Documents and Settings\gsingers\.maven\repository\commons-digester\jars\commons-digester-1.6.jar;C:\Documents and Settings\gsingers\.maven\repository\commons-lang\jars\commons-lang-2.0.jar;C:\Documents and Settings\gsingers\.maven\repository\commons-cli\jars\commons-cli-1.0.jar;C:\Documents and Settings\gsingers\.maven\repository\junit\jars\junit-3.8.1.jar;C:\Documents and Settings\gsingers\.maven\repository\xmlunit\jars\xmlunit-1.0.jar;C:\Documents and Settings\gsingers\.maven\repository\jtidy\jars\jtidy-r8.jar;C:\Documents and Settings\gsingers\.maven\repository\jdom\jars\jdom-1.0.jar;C:\Documents and Settings\gsingers\.maven\repository\commons-configuration\jars\commons-configuration-1.1.jar;C:\Documents and Settings\gsingers\.maven\repository\j2ee\jars\j2ee-1.3.1.jar;C:\Documents and Settings\gsingers\.maven\repository\commons-primitives\jars\commons-primitives-1.0.jar;C:\Documents and Settings\gsingers\.maven\repository\javahelp\jars\jhall-2.0.jar;C:\Documents and Settings\gsingers\.maven\repository\jaxb\jars\jaxb-api.jar;C:\Documents and Settings\gsingers\.maven\repository\jaxb\jars\jaxb-impl.jar;C:\Documents and Settings\gsingers\.maven\repository\jaxb\jars\jaxb-libs.jar;C:\Documents and Settings\gsingers\.maven\repository\jaxb\jars\jaxb-xjc.jar;C:\Documents and Settings\gsingers\.maven\repository\jaxb\jars\namespace.jar;C:\Documents and Settings\gsingers\.maven\repository\jaxb\jars\relaxngDatatype.jar;C:\j2sdk1.4.2_05\jre\lib\charsets.jar;C:\j2sdk1.4.2_05\jre\lib\jce.jar;C:\j2sdk1.4.2_05\jre\lib\jsse.jar;C:\j2sdk1.4.2_05\jre\lib\plugin.jar;C:\j2sdk1.4.2_05\jre\lib\rt.jar;C:\j2sdk1.4.2_05\jre\lib\sunrsasign.jar;C:\j2sdk1.4.2_05\jre\lib\ext\dnsns.jar;C:\j2sdk1.4.2_05\jre\lib\ext\ldapsec.jar;C:\j2sdk1.4.2_05\jre\lib\ext\localedata.jar;C:\j2sdk1.4.2_05\jre\lib\ext\sunjce_provider.jar;C:\ENG\Noodles\src\test\resources;C:\ENG\Noodles\src\main\resources;C:\Program Files\JetBrains\IntelliJ IDEA 5.0\lib\idea_rt.jar, idea.launcher.port=7554, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0, sun.cpu.endian=little, sun.os.patch.level=Service Pack 2, java.io.tmpdir=C:\DOCUME~1\gsingers\LOCALS~1\Temp\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, os.arch=x86, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.ext.dirs=C:\j2sdk1.4.2_05\jre\lib\ext, user.dir=C:\ENG\Noodles, line.separator=
, java.vm.name=Java HotSpot(TM) Client VM, file.encoding=UTF-8, java.specification.version=1.4, hibernate.c3p0.max_statements=50, hibernate.show_sql=true}
734 DEBUG cfg.Configuration - Preparing to build session factory with filters : {}
734 DEBUG cfg.Configuration - processing extends queue
734 DEBUG cfg.Configuration - processing collection mappings
734 DEBUG cfg.Configuration - processing native query and ResultSetMapping mappings
734 DEBUG cfg.Configuration - processing association property references
734 DEBUG cfg.Configuration - processing foreign key constraints
828 INFO connection.C3P0ConnectionProvider - C3P0 using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost/noodle
828 INFO connection.C3P0ConnectionProvider - Connection properties: {user=postgres, password=****}
828 INFO connection.C3P0ConnectionProvider - autocommit mode: false
1015 INFO log.MLog - MLog clients using log4j logging.
1046 INFO c3p0.C3P0Registry - Initializing c3p0-0.9.0 [built 11-July-2005 00:43:29 -0400; debug? true; trace: 10]
1359 INFO c3p0.PoolBackedDataSource - Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@edf3f6 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@1fe1feb [ 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, identityToken -> 1fe1feb, idleConnectionTestPeriod -> 0, initialPoolSize -> 5, maxIdleTime -> 1800, maxPoolSize -> 20, maxStatements -> 50, maxStatementsPerConnection -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1632847 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1632847, jdbcUrl -> jdbc:postgresql://localhost/noodle, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -> edf3f6, numHelperThreads -> 3 ]
2609 INFO cfg.SettingsFactory - RDBMS: PostgreSQL, version: 8.1.1
2609 INFO cfg.SettingsFactory - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.1 JDBC3 with SSL (build 404)
2640 INFO dialect.Dialect - Using dialect: org.hibernate.dialect.PostgreSQLDialect
2640 INFO transaction.TransactionFactoryFactory - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
2640 INFO transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
2640 INFO cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
2640 INFO cfg.SettingsFactory - Automatic session close at end of transaction: disabled
2656 INFO cfg.SettingsFactory - JDBC batch size: 15
2656 INFO cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
2656 INFO cfg.SettingsFactory - Scrollable result sets: enabled
2656 DEBUG cfg.SettingsFactory - Wrap result sets: disabled
2656 INFO cfg.SettingsFactory - JDBC3 getGeneratedKeys(): disabled
2656 INFO cfg.SettingsFactory - Connection release mode: auto
2656 INFO cfg.SettingsFactory - Default batch fetch size: 1
2656 INFO cfg.SettingsFactory - Generate SQL with comments: disabled
2656 INFO cfg.SettingsFactory - Order SQL updates by primary key: disabled
2656 INFO cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
2656 INFO ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
2656 INFO cfg.SettingsFactory - Query language substitutions: {}
2656 INFO cfg.SettingsFactory - Second-level cache: enabled
2656 INFO cfg.SettingsFactory - Query cache: disabled
2656 INFO cfg.SettingsFactory - Cache provider: org.hibernate.cache.EhCacheProvider
2671 INFO cfg.SettingsFactory - Optimize cache for minimal puts: disabled
2671 INFO cfg.SettingsFactory - Structured second-level cache entries: disabled
2671 DEBUG exception.SQLExceptionConverterFactory - Using dialect defined converter
2671 INFO cfg.SettingsFactory - Echoing all SQL to stdout
2671 INFO cfg.SettingsFactory - Statistics: disabled
2671 INFO cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
2671 INFO cfg.SettingsFactory - Default entity-mode: pojo
2750 INFO impl.SessionFactoryImpl - building session factory
2750 DEBUG impl.SessionFactoryImpl - Session factory constructed with filter configurations : {}
2750 DEBUG impl.SessionFactoryImpl - instantiating session factory with properties: {java.vendor=Sun Microsystems Inc., show_sql=true, hibernate.connection.url=jdbc:postgresql://localhost/noodle, os.name=Windows XP, hbm2ddl.auto=update, sun.boot.class.path=C:\j2sdk1.4.2_05\jre\lib\rt.jar;C:\j2sdk1.4.2_05\jre\lib\i18n.jar;C:\j2sdk1.4.2_05\jre\lib\sunrsasign.jar;C:\j2sdk1.4.2_05\jre\lib\jsse.jar;C:\j2sdk1.4.2_05\jre\lib\jce.jar;C:\j2sdk1.4.2_05\jre\lib\charsets.jar;C:\j2sdk1.4.2_05\jre\classes, hibernate.current_session_context_class=thread, hibernate.c3p0.max_size=20, sun.java2d.fontpath=, java.vm.specification.vendor=Sun Microsystems Inc., java.runtime.version=1.4.2_05-b04, hibernate.c3p0.min_size=5, user.name=gsingers, connection.driver_class=org.postgresql.Driver, idea.launcher.bin.path=C:\Program Files\JetBrains\IntelliJ IDEA 5.0\bin, hibernate.c3p0.timeout=1800, user.language=en, sun.boot.library.path=C:\j2sdk1.4.2_05\jre\bin, dialect=org.hibernate.dialect.PostgreSQLDialect, java.version=1.4.2_05, user.timezone=, sun.arch.data.model=32, java.endorsed.dirs=C:\j2sdk1.4.2_05\jre\lib\endorsed, sun.cpu.isalist=pentium i486 i386, file.encoding.pkg=sun.io, file.separator=\, java.specification.name=Java Platform API Specification, hibernate.cglib.use_reflection_optimizer=true, java.class.version=48.0, user.country=US, connection.url=jdbc:postgresql://localhost/noodle, java.home=C:\j2sdk1.4.2_05\jre, java.vm.info=mixed mode, os.version=5.1, transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory, hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory, path.separator=;, connection.password=postgres, java.vm.version=1.4.2_05-b04, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, hibernate.connection.password=postgres, user.variant=, java.awt.printerjob=sun.awt.windows.WPrinterJob, sun.io.unicode.encoding=UnicodeLittle, awt.toolkit=sun.awt.windows.WToolkit, hibernate.connection.username=postgres, user.home=C:\Documents and Settings\gsingers, java.specification.vendor=Sun Microsystems Inc., hibernate.hbm2ddl.auto=update, java.library.path=C:\j2sdk1.4.2_05\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\Perl\bin\;C:\Python23\.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Adaptec Shared\System;C:\WINDOWS\system32\nls;C:\WINDOWS\system32\nls\ENGLISH;C:\PROGRA~1\ULTRAE~1;C:\PROGRA~1\Tcl\bin;c:\ANT\bin;C:\j2sdk1.4.2_05\bin;c:\ENG\bin;C:\Program Files\GNU\WinCvs 1.2;c:\python23;C:\mysql\bin;C:\ENG\eQuery\TextTagger\bin;C:\Program Files\Apache Software Foundation\Maven 1.1-beta-2\bin;C:\Program Files\Subversion\bin;C:\Program Files\Common Files\GTK\2.0\bin;C:\Program Files\PostgreSQL\8.1\bin;c:\cygwin\bin;C:\Program Files\QuickTime\QTSystem\;C:\Sun\jwsdp-1.5\jwsdp-shared\bin, java.vendor.url=http://java.sun.com/, hibernate.connection.driver_class=org.postgresql.Driver, connection.username=postgres, java.vm.vendor=Sun Microsystems Inc., hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, java.class.path=C:\ENG\Noodles\target\classes;C:\Documents and Settings\gsingers\.maven\repository\commons-collections\jars\commons-collections-2.1.1.jar;C:\Documents and Settings\gsingers\.maven\repository\xerces\jars\xercesImpl-2.6.2.jar;C:\Documents and Settings\gsingers\.maven\repository\xml-apis\jars\xml-apis-1.0.b2.jar;C:\Documents and Settings\gsingers\.maven\repository\xalan\jars\xalan-2.7.0.jar;C:\Documents and Settings\gsingers\.maven\repository\hibernate\jars\hibernate-3.1.2.jar;C:\Documents and Settings\gsingers\.maven\repository\antlr\jars\antlr-2.7.6rc1.jar;C:\Documents and Settings\gsingers\.maven\repository\cglib\jars\cglib-2.1.3.jar;C:\Documents and Settings\gsingers\.maven\repository\dom4j\jars\dom4j-1.6.1.jar;C:\Documents and Settings\gsingers\.maven\repository\ehcache\jars\ehcache-1.1.jar;C:\Documents and Settings\gsingers\.maven\repository\jta\jars\jta-UNKNOWN.jar;C:\Documents and Settings\gsingers\.maven\repository\asm\jars\asm-1.5.3.jar;C:\Documents and Settings\gsingers\.maven\repository\jdbc\jars\jdbc2_0-stdext.jar;C:\Documents and Settings\gsingers\.maven\repository\asm\jars\asm-attrs-1.5.3.jar;C:\Documents and Settings\gsingers\.maven\repository\c3p0\jars\c3p0-0.9.0.jar;C:\Documents and Settings\gsingers\.maven\repository\postgresql\jars\postgresql-8.1-404.jdbc3.jar;C:\Documents and Settings\gsingers\.maven\repository\commons-logging\jars\commons-logging-1.0.4.jar;C:\Documents and Settings\gsingers\.maven\repository\commons-beanutils\jars\commons-beanutils-1.7-dev.jar;C:\Documents and Settings\gsingers\.maven\repository\hsqldb\jars\hsqldb-1.7.3.3.jar;C:\Documents and Settings\gsingers\.maven\repository\log4j\jars\log4j-1.2.8.jar;C:\Documents and Settings\gsingers\.maven\repository\commons-digester\jars\commons-digester-1.6.jar;C:\Documents and Settings\gsingers\.maven\repository\commons-lang\jars\commons-lang-2.0.jar;C:\Documents and Settings\gsingers\.maven\repository\commons-cli\jars\commons-cli-1.0.jar;C:\Documents and Settings\gsingers\.maven\repository\junit\jars\junit-3.8.1.jar;C:\Documents and Settings\gsingers\.maven\repository\xmlunit\jars\xmlunit-1.0.jar;C:\Documents and Settings\gsingers\.maven\repository\jtidy\jars\jtidy-r8.jar;C:\Documents and Settings\gsingers\.maven\repository\jdom\jars\jdom-1.0.jar;C:\Documents and Settings\gsingers\.maven\repository\commons-configuration\jars\commons-configuration-1.1.jar;C:\Documents and Settings\gsingers\.maven\repository\j2ee\jars\j2ee-1.3.1.jar;C:\Documents and Settings\gsingers\.maven\repository\commons-primitives\jars\commons-primitives-1.0.jar;C:\Documents and Settings\gsingers\.maven\repository\javahelp\jars\jhall-2.0.jar;C:\Documents and Settings\gsingers\.maven\repository\jaxb\jars\jaxb-api.jar;C:\Documents and Settings\gsingers\.maven\repository\jaxb\jars\jaxb-impl.jar;C:\Documents and Settings\gsingers\.maven\repository\jaxb\jars\jaxb-libs.jar;C:\Documents and Settings\gsingers\.maven\repository\jaxb\jars\jaxb-xjc.jar;C:\Documents and Settings\gsingers\.maven\repository\jaxb\jars\namespace.jar;C:\Documents and Settings\gsingers\.maven\repository\jaxb\jars\relaxngDatatype.jar;C:\j2sdk1.4.2_05\jre\lib\charsets.jar;C:\j2sdk1.4.2_05\jre\lib\jce.jar;C:\j2sdk1.4.2_05\jre\lib\jsse.jar;C:\j2sdk1.4.2_05\jre\lib\plugin.jar;C:\j2sdk1.4.2_05\jre\lib\rt.jar;C:\j2sdk1.4.2_05\jre\lib\sunrsasign.jar;C:\j2sdk1.4.2_05\jre\lib\ext\dnsns.jar;C:\j2sdk1.4.2_05\jre\lib\ext\ldapsec.jar;C:\j2sdk1.4.2_05\jre\lib\ext\localedata.jar;C:\j2sdk1.4.2_05\jre\lib\ext\sunjce_provider.jar;C:\ENG\Noodles\src\test\resources;C:\ENG\Noodles\src\main\resources;C:\Program Files\JetBrains\IntelliJ IDEA 5.0\lib\idea_rt.jar, idea.launcher.port=7554, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0, sun.cpu.endian=little, sun.os.patch.level=Service Pack 2, java.io.tmpdir=C:\DOCUME~1\gsingers\LOCALS~1\Temp\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, os.arch=x86, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.ext.dirs=C:\j2sdk1.4.2_05\jre\lib\ext, user.dir=C:\ENG\Noodles, line.separator=
, java.vm.name=Java HotSpot(TM) Client VM, file.encoding=UTF-8, java.specification.version=1.4, hibernate.show_sql=true, hibernate.c3p0.max_statements=50}
2796 WARN config.Configurator - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/Documents%20and%20Settings/gsingers/.maven/repository/ehcache/jars/ehcache-1.1.jar!/ehcache-failsafe.xml
3281 DEBUG entity.AbstractEntityPersister - Static SQL for entity: Junk
3281 DEBUG entity.AbstractEntityPersister - Version select: select junkId from junk where junkId =?
3281 DEBUG entity.AbstractEntityPersister - Snapshot select: select junk_.junkId, junk_.junk as junk0_ from junk junk_ where junk_.junkId=?
3281 DEBUG entity.AbstractEntityPersister - Insert 0: insert into junk (junk, junkId) values (?, ?)
3281 DEBUG entity.AbstractEntityPersister - Update 0: update junk set junk=? where junkId=?
3281 DEBUG entity.AbstractEntityPersister - Delete 0: delete from junk where junkId=?
3312 DEBUG entity.EntityLoader - Static select for entity Junk: select junk0_.junkId as junkId0_0_, junk0_.junk as junk0_0_ from junk junk0_ where junk0_.junkId=?
3312 DEBUG entity.EntityLoader - Static select for entity Junk: select junk0_.junkId as junkId0_0_, junk0_.junk as junk0_0_ from junk junk0_ where junk0_.junkId=?
3312 DEBUG entity.EntityLoader - Static select for entity Junk: select junk0_.junkId as junkId0_0_, junk0_.junk as junk0_0_ from junk junk0_ where junk0_.junkId=? for update
3312 DEBUG entity.EntityLoader - Static select for entity Junk: select junk0_.junkId as junkId0_0_, junk0_.junk as junk0_0_ from junk junk0_ where junk0_.junkId=? for update
3328 DEBUG entity.EntityLoader - Static select for action ACTION_MERGE on entity Junk: select junk0_.junkId as junkId0_0_, junk0_.junk as junk0_0_ from junk junk0_ where junk0_.junkId=?
3328 DEBUG entity.EntityLoader - Static select for action ACTION_REFRESH on entity Junk: select junk0_.junkId as junkId0_0_, junk0_.junk as junk0_0_ from junk junk0_ where junk0_.junkId=?
3343 DEBUG impl.SessionFactoryObjectFactory - initializing class SessionFactoryObjectFactory
3343 DEBUG impl.SessionFactoryObjectFactory - registered: 0066d4ed09451af50109451af7e60000 (unnamed)
3343 INFO impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
3343 DEBUG impl.SessionFactoryImpl - instantiated session factory
3343 INFO hbm2ddl.SchemaUpdate - Running hbm2ddl schema update
3343 INFO hbm2ddl.SchemaUpdate - fetching database metadata
3375 INFO hbm2ddl.SchemaUpdate - updating schema
3375 DEBUG cfg.Configuration - processing extends queue
3375 DEBUG cfg.Configuration - processing collection mappings
3375 DEBUG cfg.Configuration - processing native query and ResultSetMapping mappings
3375 DEBUG cfg.Configuration - processing association property references
3375 DEBUG cfg.Configuration - processing foreign key constraints
3437 INFO hbm2ddl.TableMetadata - table found: public.junk
3437 INFO hbm2ddl.TableMetadata - columns: [junkid, junk]
3453 INFO hbm2ddl.TableMetadata - foreign keys: []
3453 INFO hbm2ddl.TableMetadata - indexes: [junk_pkey]
3453 INFO hbm2ddl.SchemaUpdate - schema update complete
3468 DEBUG impl.SessionFactoryImpl - Checking 0 named HQL queries
3468 DEBUG impl.SessionFactoryImpl - Checking 0 named SQL queries
3468 INFO HibernateTest - --------------------test()---------------------
3546 DEBUG impl.SessionImpl - opened session at timestamp: 4666678185631744
3671 DEBUG context.ThreadLocalSessionContext - allowing method [beginTransaction] in non-transacted context
3671 DEBUG context.ThreadLocalSessionContext - allowing proxied method [beginTransaction] to proceed to real session
3671 DEBUG transaction.JDBCTransaction - begin
3671 DEBUG jdbc.ConnectionManager - opening JDBC connection
3671 DEBUG util.JDBCExceptionReporter - Cannot open connection [???]
java.sql.SQLException: com.mchange.v2.c3p0.PoolBackedDataSource@edf3f6 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@1fe1feb [ 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, identityToken -> 1fe1feb, idleConnectionTestPeriod -> 0, initialPoolSize -> 5, maxIdleTime -> 1800, maxPoolSize -> 20, maxStatements -> 50, maxStatementsPerConnection -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1632847 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1632847, jdbcUrl -> jdbc:postgresql://localhost/noodle, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -> edf3f6, numHelperThreads -> 3 ] has been closed() -- you can no longer use it.
at com.mchange.v2.c3p0.PoolBackedDataSource.assertCpds(PoolBackedDataSource.java:234)
at com.mchange.v2.c3p0.PoolBackedDataSource.getPoolManager(PoolBackedDataSource.java:246)
at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:94)
at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:35)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:360)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:122)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:125)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1309)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
at $Proxy0.beginTransaction(Unknown Source)
at HibernateTest.test(HibernateTest.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at com.intellij.rt.execution.junit2.IdeaJUnitAgent.doRun(IdeaJUnitAgent.java:58)
at junit.textui.TestRunner.start(TestRunner.java:172)
at com.intellij.rt.execution.junit.TextTestRunner2.startRunnerWithArgs(TextTestRunner2.java:23)
at com.intellij.rt.execution.junit2.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:98)
at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
3687 WARN util.JDBCExceptionReporter - SQL Error: 0, SQLState: null
3687 ERROR util.JDBCExceptionReporter - com.mchange.v2.c3p0.PoolBackedDataSource@edf3f6 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@1fe1feb [ 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, identityToken -> 1fe1feb, idleConnectionTestPeriod -> 0, initialPoolSize -> 5, maxIdleTime -> 1800, maxPoolSize -> 20, maxStatements -> 50, maxStatementsPerConnection -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1632847 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1632847, jdbcUrl -> jdbc:postgresql://localhost/noodle, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -> edf3f6, numHelperThreads -> 3 ] has been closed() -- you can no longer use it.

org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:363)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:122)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:125)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1309)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
at $Proxy0.beginTransaction(Unknown Source)
at HibernateTest.test(HibernateTest.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: java.sql.SQLException: com.mchange.v2.c3p0.PoolBackedDataSource@edf3f6 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@1fe1feb [ 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, identityToken -> 1fe1feb, idleConnectionTestPeriod -> 0, initialPoolSize -> 5, maxIdleTime -> 1800, maxPoolSize -> 20, maxStatements -> 50, maxStatementsPerConnection -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1632847 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1632847, jdbcUrl -> jdbc:postgresql://localhost/noodle, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -> edf3f6, numHelperThreads -> 3 ] has been closed() -- you can no longer use it.
at com.mchange.v2.c3p0.PoolBackedDataSource.assertCpds(PoolBackedDataSource.java:234)
at com.mchange.v2.c3p0.PoolBackedDataSource.getPoolManager(PoolBackedDataSource.java:246)
at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:94)
at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:35)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:360)
... 34 more


Process finished with exit code -1

_________________
------------------------------------
Grant Ingersoll
http://www.grantingersoll.com


Top
 Profile  
 
 Post subject: More info
PostPosted: Wed Feb 08, 2006 11:03 am 
Newbie

Joined: Mon Feb 06, 2006 5:24 pm
Posts: 4
So, I have done some debugging of this, and it seems that the SchemaUpdate class is calling connectionProvider.close() on line 175, which then proceeds to destroy the data source on line 118 of the C3P0ConnectionProvider class. Then, when I go to begin doing my real work, by opening a transaction, it tries to get a new connection from the Data Source (which for some reason is the one that was just destroyed) and the PoolBackedDataSource throws the offending exception on line 234 because, as far as it is concerned, the Data Source has been destroyed.

Since SchemaUpdate isn't being called when hbm2ddl.auto is set to create this is never an issue.

I have my C3P0 properties set as in http://www.hibernate.org/hib_docs/refer ... ernatejdbc (which can be seen in the configuration I posted earlier.)

I can reproduce this every time and have a simple test case for below:

public void test()
{
log.info("--------------------test()---------------------");
// Create the initial SessionFactory from the default configuration files
SessionFactory sessionFactory = configure("update");
assertTrue("sessionFactory is null and it shouldn't be", sessionFactory != null);
Session session = sessionFactory.getCurrentSession();
Transaction tx = null;
try
{
tx = session.beginTransaction();
assertTrue("Exception should have been thrown and it wasn't", false);
}
catch (HibernateException e)
{
if (tx != null)
{
tx.rollback();
}
}
session.close();
sessionFactory.close();
sessionFactory = configure("create");
session = sessionFactory.getCurrentSession();
Junk junk = new Junk("This is a test string");
tx = session.beginTransaction();
session.save(junk);
tx.commit();
assertTrue("junk.getId() is not set", junk.getId().longValue() != -1);

log.info("--------------------end test()---------------------");
}

private SessionFactory configure(String hbm2ddl)
{
SessionFactory sessionFactory = null;
try
{
// Replace with Configuration() if you don't use annotations or JDK 5.0
Configuration configuration = new Configuration();
// This custom entity resolver supports entity placeholders in XML mapping files
// and tries to resolve them on the classpath as a resource
//configuration.setEntityResolver(new ImportFromClasspathEntityResolver());

// Read not only hibernate.properties, but also hibernate.cfg.xml
configuration.configure();
log.info("------------------------");
log.info("hbm: " + configuration.getProperty("hibernate.hbm2ddl.auto"));
configuration.setProperty("hibernate.hbm2ddl.auto", hbm2ddl);
log.info("hbm: " + configuration.getProperty("hibernate.hbm2ddl.auto"));
log.info("------------------------");

if (configuration.getProperty(Environment.SESSION_FACTORY_NAME) != null)
{
// Let Hibernate bind the factory to JNDI
configuration.buildSessionFactory();
}
else
{
// or use static variable handling
sessionFactory = configuration.buildSessionFactory();
}

}
catch (Throwable ex)
{
// We have to catch Throwable, otherwise we will miss
// NoClassDefFoundError and other subclasses of Error
log.error("Building SessionFactory failed.", ex);
throw new ExceptionInInitializerError(ex);
}
return sessionFactory;
}
}

_________________
------------------------------------
Grant Ingersoll
http://www.grantingersoll.com


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