Hello ,
My application is designed with Spring MVC , hibernate and SQL Server 2008.
So here issue we are facing is when ever the page get loaded(fetching the data from DB) , It is freezing at the below point for 10-20 seconds(When the sessionfactory is created for first time)
SessionFactory factory= HibernateUtil.getSessionFactory();
Pasting my hibernate.cfg .xml and .java below
Code:
<hibernate-configuration>
<session-factory> <!-- Database connection settings -->
<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="connection.url">************</property>
<property name="connection.username">*******</property>
<property name="connection.password">******</property> <!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">20</property> <!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.SQLServer2008Dialect</property> <!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property> <!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">validate</property>
<mapping class="com.**********************"/>
<mapping class="com.**********************"/>
<mapping class="com.**********************"/>
<mapping class="com.**********************"/>
<mapping class="com.**********************"/>
<mapping class="com.**********************"/>
</session-factory>
</hibernate-configuration>
HibernateUtil.java
Code:
public class HibernateUtil {
static SessionFactory factory;
static{
Configuration cfg = new Configuration();
factory = cfg.configure().buildSessionFactory();
}
public static SessionFactory getSessionFactory(){
return factory;
}
}
Any guidance to resolve this issue is appreciated.
Note : We are using entity classes instead of xml
Thanks in advance ,
Anish