我们正在将项目迁移到Hibernate 5,并且启动时间很慢。
Hibernate似乎在org.hibernate.persister.walking.spi.MetamodelGraphWalker
2018-02-06 07:24:49,167 DEBUG [org.hibernate.persister.walking.spi.MetamodelGraphWalker] - <Visiting attribute path : s23>
2018-02-06 07:24:49,167 DEBUG [org.hibernate.persister.walking.spi.MetamodelGraphWalker] - <Visiting attribute path : s24>
2018-02-06 07:24:49,167 DEBUG [org.hibernate.persister.walking.spi.MetamodelGraphWalker] - <Visiting attribute path : s25>
2018-02-06 07:24:49,167 DEBUG [org.hibernate.persister.walking.spi.MetamodelGraphWalker] - <Visiting attribute path : s26>
2018-02-06 07:24:49,167 DEBUG [org.hibernate.persister.walking.spi.MetamodelGraphWalker] - <Visiting attribute path : s27>
2018-02-06 07:24:49,167 DEBUG [org.hibernate.persister.walking.spi.MetamodelGraphWalker] - <Visiting attribute path : s28>
2018-02-06 07:24:49,167 DEBUG [org.hibernate.persister.walking.spi.MetamodelGraphWalker] - <Visiting attribute path : s29>
2018-02-06 07:24:49,167 DEBUG [org.hibernate.persister.walking.spi.MetamodelGraphWalker] - <Visiting attribute path : s30>
2018-02-06 07:24:49,167 DEBUG [org.hibernate.persister.walking.spi.MetamodelGraphWalker] - <Visiting attribute path : s31>
以下是Hibernate的配置方式:
hibernateProp.put(Environment.HBM2DDL_AUTO, "update");
hibernateProp.put(Environment.CURRENT_SESSION_CONTEXT_CLASS,"org.hibernate.context.internal.ThreadLocalSessionContext");
hibernateProp.put(Environment.DIALECT, "com.orbis.portal.OrbisSQLServerDialect");
hibernateProp.put("org.hibernate.flushMode", "COMMIT");
hibernateProp.put(Environment.USE_QUERY_CACHE, "true");
hibernateProp.put(Environment.CACHE_REGION_FACTORY, "org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory");
hibernateProp.put(Environment.CACHE_PROVIDER_CONFIG, "classpath:ehcache.xml");
hibernateProp.put(Environment.USE_SECOND_LEVEL_CACHE, "true");
hibernateProp.put("hibernate.enable_lazy_load_no_trans", "true");
hibernateProp.put("hibernate.jdbc.use_get_generated_keys", "true");
以下是会话工厂的构建方式:
final BootstrapServiceRegistry bootstrapServiceRegistry = new BootstrapServiceRegistryBuilder()
.enableAutoClose()
.applyIntegrator(MetadataExtractorIntegrator.INSTANCE).build();
registry = new StandardServiceRegistryBuilder(bootstrapServiceRegistry)
.applySettings(getHibernateSettings()).build();
MetadataSources sources = new MetadataSources(registry);
processHbmMappings(sources);
processAnnotatedMappings(sources);
Metadata metadata = sources.getMetadataBuilder().build();
sessionFactory = metadata.getSessionFactoryBuilder().build();
有什么想法吗?
更新
OrbisSQLServerDialect只是扩展SQLServer2008Dialect来改变几个列类型
public class OrbisSQLServerDialect extends SQLServer2008Dialect
{
public OrbisSQLServerDialect()
{
super();
registerColumnType(Types.TIMESTAMP, "datetime");
registerColumnType(Types.BOOLEAN, "tinyint");
}
}