sql查询在Hibernate中很慢,在mysql上快

时间:2017-02-14 14:19:23

标签: java mysql hibernate

我有一个非常简单的查询来选择表中的所有行。在休眠状态下,它总是需要大约17-18秒。我指定,show_sql是真的。我将sql命令直接复制到mysql,耗时0.00022秒......

这是查询:

SELECT 
    organizati0_.id AS id1_5_,
    organizati0_.adminList AS adminLis2_5_,
    organizati0_.demoAccount AS demoAcco3_5_,
    organizati0_.disabled AS disabled4_5_,
    organizati0_.enduserCredits AS enduserC5_5_,
    organizati0_.name AS name6_5_,
    organizati0_.pushNotificationRoom AS pushNoti7_5_,
    organizati0_.totalLicenses AS totalLic8_5_,
    organizati0_.usedLicenses AS usedLice9_5_
FROM
    organization organizati0_

这是查询的代码:

Session session = ThreadSessionHolder.getThreadSession();
Query query = session.createQuery("from Organization ");
List list = query.list();
return list;

任何想法?这让我疯狂

1 个答案:

答案 0 :(得分:0)

我发现了这个问题。

我在构造函数中执行了一个初始化操作,在选择所有

时不应该这样做