我正在使用JPA,hibernate和Oracle DB。 在多次调用方法findAll(..)时(比如说1000),每次Oracle打开一个新的游标。提交实体管理器事务或关闭entityManager后,打开的游标不会关闭(lem.close())。问题是oracle打开1000个游标并达到最大打开游标限制并抛出错误ORA-01000:超出最大打开游标。如何强制oracle关闭打开的游标?
public List<T> findAll(Long id1, Long id2, Long id3, boolean cacheResults) {
EntityManager lem = emf.createEntityManager();
lem.getTransaction().begin();
StringBuilder sb = new StringBuilder();
boolean first = true;
List<T> listRowValue = lem.createNativeQuery("select * from MASTER b where id = " + id1 + " and id = " + id2 + " and id = " + id3)
.getResultList();
lem.getTransaction().commit();
lem.close();
return listRowValue;
}