-->
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: Guaranteeing Hibernate doesn't use connection until needed?
PostPosted: Thu Oct 13, 2011 9:13 am 
Newbie

Joined: Thu Oct 13, 2011 8:49 am
Posts: 6
Hi all,

FYI, I'm using JPA via Hibernate with Spring's LocalContainerEntityManagerFactoryBean & my AbstractRoutingDataSource subclass.

It appears that Hibernate is grabbing a connection at initialization time. How would I configure Hibernate so that it does not connect to the database during SessionFactory creation at all?

I have set (among other things)

hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.connection.pool_size=0


but upon SessionFactory creation, it still obtains a connection. I'm thinking it may be for schema validate/update/create/create-drop, depending on the hibernate.hbm2ddl.auto property.

If I'm correct about that, what value I can set hibernate.hbm2ddl.auto to in order to have Hibernate not connect to the database until a Session is created and it's actually needed for a flush or something, effectively telling Hibernate that I know the schema is correct?

Next question, once I can stop Hibernate from getting a connection at SessionFactory creation time: how can I ensure that Hibernate doesn't hold on to any connections at all? Is hibernate.connection.pool_size=0 sufficient?

Thanks,
Matthew


Top
 Profile  
 
 Post subject: Re: Guaranteeing Hibernate doesn't use connection until needed?
PostPosted: Thu Oct 13, 2011 7:08 pm 
Newbie

Joined: Thu Oct 13, 2011 8:49 am
Posts: 6
Ok, made some progress:
Code:
hibernate.temp.use_jdbc_metadata_defaults=false
hibernate.hbm2ddl.auto=none
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.connection.pool_size=0
I had to dig (debug) to find hibernate.temp.use_jdbc_metadata_defaults.

I'm still not totally convinced that this is complete. A couple of things, though: I'm not sure that hibernate.temp.use_jdbc_metadata_defaults will be around forever, and the value "none" for
hibernate.hbm2ddl.auto didn't seem to be documented.

Any other suggestions?

-matthew


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.