-->
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.  [ 7 posts ] 
Author Message
 Post subject: hbm2ddl Tool ConnectionProvider Bug?
PostPosted: Thu Feb 02, 2006 1:15 pm 
Newbie

Joined: Thu Aug 18, 2005 5:39 pm
Posts: 8
Hello all,

This is more aimed at the Hibernate developers. In the SchemaUpdate, SchemaValidate classes, there seems to be a habit of closing the ConnectionProvider (validate() & execute() methods respectively).

The effect of this seems to be is that when you use Hibernate in a standalone with a C3P0ConnectionProvider hibernate can no use the provider, complaining it has been closed.

Any comments on this? Solutions?

Richard....


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 8:21 am 
Newbie

Joined: Mon Dec 26, 2005 12:35 pm
Posts: 7
It wasn't a problem with 3.0.5 where a new provider was created for each tool (SchemaUpdate, ...), but as of 3.1.2, it appears the same instance is obtained from the Settings (some sort of optimization?). But as the instance is closed, it cannot be reused...

This is really annoying (to us, at least). Any hint/suggestion/comment from developers would be really appreciated.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 8:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh, I dont understand the problem.

The current code creates its own connectionprovider and thus needs to clean up afterwards. When is there any need for reusing this connectionprovider?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 9:41 am 
Newbie

Joined: Mon Dec 26, 2005 12:35 pm
Posts: 7
Here's what I understood from reading the source code:

- I have a standalone application
- when I first connect to the db, Hibernate updates the database using SchemaUpdate from SessionFactoryImpl. This schema update is created using the SchemaUpdate(cfg, settings) constructor, which doesn't instantiate a new ConnectionProvider but uses the one from the settings
Code:
        public SchemaUpdate(Configuration cfg, Settings settings) throws HibernateException {
                this.configuration = cfg;
                dialect = settings.getDialect();
                connectionProvider = settings.getConnectionProvider();
        exceptions = new ArrayList();
        }

- when SchemaUpdate is done, it closes the ConnectionProvider, which cannot be used afterwards
- afterwards, when I try to do something on the database, it appears the (closed) connection provider from the settings is used and it explodes...

Code:
11:52:45.217 DEBUG [main] org.hibernate.util.JDBCExceptionReporter                      - Cannot open connection [???]
java.sql.SQLException: com.mchange.v2.c3p0.PoolBackedDataSource@11d329d [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@16c1bce [ 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 -> 16c1bce, idleConnectionTestPeriod -> 3600, initialPoolSize -> 0, maxIdleTime -> 100, maxPoolSize -> 20, maxStatements -> 50, maxStatementsPerConnection -> 0, minPoolSize -> 0, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1d50fd2 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1d50fd2, jdbcUrl -> jdbc:derby:Producer_db;create=true, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> true, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -> 11d329d, numHelperThreads -> 3 ] has been closed() -- you can no longer use it.


(right now, we're envisioning a temporary locally patched SessionFactoryImpl where we use the old SchemaUpdate(cfg,connectionProperties) constructor)
Code:
        public SchemaUpdate(Configuration cfg, Properties connectionProperties) throws HibernateException {
                this.configuration = cfg;
                dialect = Dialect.getDialect(connectionProperties);
                Properties props = new Properties();
                props.putAll( dialect.getDefaultProperties() );
                props.putAll(connectionProperties);
                connectionProvider = ConnectionProviderFactory.newConnectionProvider(props);
        exceptions = new ArrayList();
        }


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 9:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
put this in hibernate core jira - this is a bug.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 10:04 am 
Newbie

Joined: Mon Dec 26, 2005 12:35 pm
Posts: 7
Ok. Done. It is Issue HHH-1445

http://opensource2.atlassian.com/projec ... watch=true


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 10, 2006 4:32 am 
Newbie

Joined: Mon Dec 26, 2005 12:35 pm
Posts: 7
Bug fixed, thanks.


Quote:
Fix Version/s: 3.2, 3.1.3


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