Hello all,
I am new to hibernate and am trying to figure out why I am encountering issues with the hbm2ddl.auto configuration. I am using the c3p0 connection pooling in conjunction with hibernate. I create a data source using c3p0 and use that as the connection data source for hibernate
With [i]hbm2ddl.auto=create [/i] (create all tables from scratch) the session factory was created successfully with no error.
However, with [i]hbm2ddl.auto=update [/i], I notice that the schema are updated and then I start getting errors in the c3p0 configuration. Any access to the database from that point starts failing because of the connection provider is closed.
When I debugged this in the hibernate code, I noticed that in line 175 of the org.hibernate.tool.hbm2ddl.SchemaUpdate class (execute method), the connection provider is closed after the update is performed. This causes the subsequent open connection operation to the database access to fail.
The connection provider should be closed only when the execute is called fwhile SchemaUpdate is run as a seperate tool. However, when this is called inside the SessionFactoryImpl (line 295), closing the connection provider causes the above issue.
Thanks for the help.
Saravanan
[b]Hibernate version: 3.1.2[/b]
[b]Mapping documents:[/b]
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:hsql://localhost:9001/attuneDb</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<!-- Session Factory Name -->
<property name="session_factory_name">attune:hibernate/HibernateFactory</property>
<!-- connection pool via c3p0. The data source is created in the SessionFactoryRegistry-->
<property name="c3p0.acquire_increment">1</property>
<property name="c3p0.idle_test_period">100</property> <!-- seconds -->
<property name="c3p0.min_size">10</property>
<property name="c3p0.max_size">20</property>
<property name="c3p0.max_statements">0</property> <!-- caching disabled if 0 -->
<property name="c3p0.timeout">200</property> <!-- seconds -->
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Update Schema on startup -->
<property name="hbm2ddl.auto">update</property>
<mapping resource="com/attune/server/objectModel/fileManager/FileSwitch.hbm.xml"/>
</session-factory>
[b]Full stack trace of any exception that occurs:[/b] Regular db open connection failure
[b]Name and version of the database you are using: [/b] Default Hypersonic database
[b]The generated SQL (show_sql=true):[/b] N/A
[b]Debug level Hibernate log excerpt:[/b] N/A
|