-->
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: Over connexion Limit / Permanent reload of Factory
PostPosted: Wed Mar 09, 2011 9:18 am 
Newbie

Joined: Tue Feb 01, 2011 8:17 pm
Posts: 7
Hi,

Hibernate run out of the pool connection limit. I really dont know why. My feeling is , i have a problem with the SessionFactory maybe.
Because each time a call the servlet, i see the INFO of the configuration loading.
I went back on a very simple configuration and it's always the case :

Example of my configuration file :

<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="connection.pool_size">5</property>
<!-- <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property> -->
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Test -->
<property name="hibernate.transaction.flush_before_completion">true</property>
<property name="hibernate.transaction.auto_close_session">true</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- this will show us all sql statements -->
<property name="hibernate.show_sql">false</property>

Example of on of my Dao class ( All of them follow this model ) :

Code:
public class BSban {
   Session session;
   
   public BSban(){}
   
   public void createBan(Ban b){
                Session session = HibernateUtil.getSessionFactory().getCurrentSession();
      try{
         session.beginTransaction();
         session.save(b);
         session.getTransaction().commit();
      }
      catch (RuntimeException e) {
         session.getTransaction().rollback();
      }
   }
}


I have to deploy my application in production in few day and i cant due to this problem , i look for a solution since 2 days, i found nothing about this problem on google :-(

Thanks


After read that :
When all mappings have been parsed by the org.hibernate.cfg.Configuration, the application must obtain a factory for org.hibernate.Session instances. This factory is intended to be shared by all application threads:
SessionFactory sessions = cfg.buildSessionFactory();
Hibernate does allow your application to instantiate more than one org.hibernate.SessionFactory. This is useful if you are using more than one database.

It's confirme my feeling , i am not suppose to see a load of hbm file at each request send to my servlet. But i use the singleton factory of hibernate. Something clear the static attribute of my Singletong factory ....

I dont know why ...


Top
 Profile  
 
 Post subject: Re: Over connexion Limit / Permanent reload of Factory
PostPosted: Wed Mar 09, 2011 5:37 pm 
Newbie

Joined: Tue Feb 01, 2011 8:17 pm
Posts: 7
Solved :

I have a call of new sessionfactory lost in my code ....


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.