我的问题可能是hibernate。
我在某些集合上有一个Fetch请求(因为我需要所有这些数据),请求需要20秒,这对我来说非常慢。 请求返回92个实体'A',对于每个实体'A' - > 2实体'A'子实体和9实体'B'的集合。
我已经像这样配置了我的休眠:
<property name="hibernate.archive.autodetection" value="class, hbm, jar"/>
<property name="hibernate.dialect" value="com.****.****.persistence.server.dialect.MyMySQLDialect" />
<property name="hibernate.connection.autocommit" value="false" />
<property name="hibernate.max_fetch_depth" value="3" />
<property name="hibernate.default_batch_fetch_size" value="16"/>
<property name="hibernate.jdbc.fetch_size" value="20"/>
<property name="hibernate.jdbc.batch_size" value="100"/>
<property name="hibernate.order_inserts" value="true"/>
<property name="hibernate.order_updates" value="true"/>
<property name="hibernate.jdbc.batch_versioned_data" value="true"/>
<property name="org.hibernate.flushMode" value="commit"/>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.generate_statistics" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>
<property name="hibernate.connection.pool_size" value="100"/>
我启用了hibernate的调试日志,看看会发生什么,我注意到在某些时刻我输了2-3s,我想知道那里发生了什么?
见:
08:34:47,008 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (EJB default - 1) Obtaining JDBC connection
08:34:47,008 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (EJB default - 1) Obtained JDBC connection
08:34:49,559 DEBUG [org.hibernate.loader.Loader] (EJB default - 1) Result set contains (possibly empty) collection: [com.****.****.persistence.server.entities.DataSet.****#34886]
[...]
08:34:49,642 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (EJB default - 1) Obtaining JDBC connection
08:34:49,642 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (EJB default - 1) Obtained JDBC connection
08:34:52,778 DEBUG [org.hibernate.loader.Loader] (EJB default - 1) Result set contains (possibly empty) collection: [com.****.****.persistence.server.entities.DataSet.****#32441]
[...]
08:34:52,936 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (EJB default - 1) Obtaining JDBC connection
08:34:52,936 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (EJB default - 1) Obtained JDBC connection
08:34:55,690 DEBUG [org.hibernate.loader.Loader] (EJB default - 1) Result set contains (possibly empty) collection: [com.****.****.persistence.server.entities.DataSet.****#24474]
[...]
08:34:55,830 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (EJB default - 1) Obtaining JDBC connection
08:34:55,830 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (EJB default - 1) Obtained JDBC connection
08:34:58,760 DEBUG [org.hibernate.loader.Loader] (EJB default - 1) Result set contains (possibly empty) collection: [com.****.****.persistence.server.entities.DataSet.****#21018]
我想当我们使用FETCH JOIN时,hibernate只发出一个请求来检索所需的数据,但似乎他提出了多次请求。
有人知道这2-3秒之间会发生什么?数据库方面?
谢谢,对不起我的英文