持久性.xml:
<properties>
<property name="showSql" value="true"/>
<property name="hibernate.dialect" value="${hibernate.dialect:org.hibernate.dialect.Oracle10gDialect}"/>
<propertyname="hibernate.connection.datasource"value="java:/alarmmgr/alarmMonitorDB"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="false"/>
<property name="hibernate.use_sql_comments" value="false"/>
<property name="hibernate.jdbc.wrap_result_sets" value="false"/>
<property name="hibernate.hibernate.cache.use_query_cache" value="true"/>
<property name="javax.persistence.query.timeout" value="1" />
</properties>
询问:
em.createQuery(query).setHint("javax.persistence.query.timeout", 1)
.setFirstResult(payload.getStart())
.setMaxResults(payload.getSize() > MAX_FETCH ? MAX_FETCH : payload.getSize())
.getResultList()
查询返回 7000 行……但超时不起作用。