目前我的应用程序使用Tomcat 6和hibernate 3,但我注意到启动非常慢,我只有大约40个实体映射。不确定这是否是由休眠引起的日志如下:
下面大约需要5分钟:
有什么想法吗?顺便说一句我已经尝试过增加tomcat内存
2016-03-01 09:18:53,933 INFO [main] SessionFactoryObjectFactory.addInstance(105) | Not binding factory to JNDI, no JNDI name configured
2016-03-01 09:24:42,046 DEBUG [main] GnrlLookupView.<clinit>(37) | Registering view: GnrlLookupView
2016-03-01 09:24:46,881 INFO [main] QuartzScheduler.<init>(209) | Quartz Scheduler v.1.6.0 created.
Hibernate配置:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource"> <ref bean="dataSource" /> </property>
<property name="mappingJarLocations">
<list>
<value>WEB-INF/lib/*-hbm.jar</value>
</list>
</property>
<property name="lobHandler">
<bean class="org.springframework.jdbc.support.lob.OracleLobHandler">
<property name="nativeJdbcExtractor">
<bean class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor" />
</property>
</bean>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.connection.SetBigStringTryClob">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop> <!-- Explicitly enabled 2nd level cache since upgrade to hibernate version 3.2.x -->
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
</props>
</property>
<property name="entityInterceptor">
<ref bean="entityAuditInterceptor" />
</property>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>ref bean="entityAuditInterceptor" />
</property>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
更新:我已经启用了更好的日志记录并且来到了下面,它打印出以下5分钟,任何想法?
SessionFactoryUtils.doGetSession(316) | Opening Hibernate Session
2016-03-01 10:46:45,468 DEBUG [main] OracleLobHandler.getClobAsString(229) | Returning Oracle CLOB as string
2016-03-01 10:46:45,468 DEBUG [main] OracleLobHandler.getClobAsString(229) | Returning Oracle CLOB as string
2016-03-01 10:46:45,468 DEBUG [main] OracleLobHandler.getClobAsString(229) | Returning Oracle CLOB as string
2016-03-01 10:46:45,483 DEBUG [main] OracleLobHandler.getClobAsString(229) | Returning Oracle CLOB as string
2016-03-01 10:46:45,483 DEBUG [main] OracleLobHandler.getClobAsString(229) | Returning Oracle CLOB as string
2016-03-01 10:46:45,483 DEBUG [main] OracleLobHandler.getClobAsString(229) | Returning Oracle CLOB as string
2016-03-01 10:44:43,487 DEBUG [main] HibernateTemplate.flushIfNecessary(389) | Eagerly flushing Hibernate session
2016-03-01 10:44:43,487 DEBUG [main] SessionFactoryUtils.closeSession(789) | Closing Hibernate Session
2016-03-01 10:44:43,487 DEBUG [main] SessionFactoryUtils.doGetSession(316) | Opening Hibernate Session
答案 0 :(得分:0)
发现答案不是由于hibernate设置,似乎在启动应用程序期间加载了大量表并尝试保存在缓存中。