在休眠状态下创建会话需要超过40秒

时间:2016-03-02 12:07:15

标签: java database hibernate session

我正在使用hibernate框架来访问数据库。创建会话需要40秒。花费那么多时间的原因是什么?

SessionFactory factory = new Configuration().configure().buildSessionFactory();

这是线路chich花费太多时间到fininsh。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration SYSTEM 
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
    <property name="hibernate.bytecode.use_reflection_optimizer">false</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://54.64.5.134:3306/cpos</property>
    <property name="hibernate.connection.username"></property>
    <property name="hibernate.connection.password"></property>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="show_sql">true</property>
    <property name="hibernate.hbm2ddl.auto">update</property>
    <property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
    <property name="net.sf.ehcache.configurationResourceName">/ehcache.xml</property>
    <property name="hibernate.cache.use_query_cache">true</property>
    <property name="hibernate.cache.use_second_level_cache">true</property>

    <property name="connection.provider_class">org.hibernate.c3p0.internal.C3P0ConnectionProvider</property>
    <property name="hibernate.c3p0.min_size">5</property>
    <property name="hibernate.c3p0.max_size">20</property>
    <property name="hibernate.c3p0.timeout">3000</property>
    <property name="hibernate.c3p0.max_statements">50</property>
    <property name="hibernate.c3p0.idle_test_period">3000</property>



    <mapping class="com.chaipoint.dppojos.CpOrderAddress" />
    <mapping class="com.chaipoint.dppojos.CpOrders" />
    <mapping class="com.chaipoint.dppojos.LocationMaster" />
    <mapping class="com.chaipoint.dppojos.CpOrderProduct" />
    <mapping class="com.chaipoint.dppojos.StoreMaster" />



</session-factory>
</hibernate-configuration>

这是我的hibernate.cgf.xml文件

0 个答案:

没有答案