Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Hibernate connection pool problem when use createSQLQuery
PostPosted: Fri Jun 02, 2017 12:07 pm 
Newbie

Joined: Fri Jun 02, 2017 11:51 am
Posts: 1
Hi,

I'm using hibernate(4.2.7) + spring (4.1.6) in a j2ee application and weblogic 12c as application server. I've code some queries in hibernate using native sql queries (using the method createSQLQuery) and after finishes it's execution I've seen how the connection pool is increase by every request I make to the web service (who use the dao code with the createSQLQuery)

This behavior does not happen when I use criteria or hql queries (there is not increment in the number of connections in the datasource). What could be the reason of this behavior. Why when I create native sql query the connection doesn't return to the connection pool after it's execution (in fact it should reuse the active connections from the data source, instead create a new one and don't put it back to the data source)

Thanks in Advice

Luis AviƱa


Top
 Profile  
 
 Post subject: Re: Hibernate connection pool problem when use createSQLQuery
PostPosted: Fri Jun 02, 2017 2:46 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1229
In a Java EE environment, you probably use JTA. For this reason, Hibernate uses aggressive connection release after every statement execution, not just native SQL queries.

The App server DataSource provides connection pooling as well as it serves the same Connection during the same JTA transaction. What you have observed is not how Hibernate works. If you don't beleive, then just debug it and point to the code that does that.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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.