JPA中的最大光标打开

时间:2015-03-27 15:41:53

标签: java multithreading jpa executorservice

以下是我的代码段。抱歉这个长码。但真的无法弄清楚为什么会这样。

    class StartProcessTask implements Callable<ProgramProcesses>{
        //constructor and fields


        @Override
        public ProgramProcesses call() throws Exception {
             ProgramProcesses programProcess=null;           
             try {
                    EntityTransaction transaction = EntityManagerUtil.getInstance().beginWfTransaction();
                    EntityTransaction asapTransaction = EntityManagerUtil.getInstance().beginAsapTransaction();

                    programProcess = programsBusinessLogic.addProgramProcesses(program, instanceId);
                    Set<ProgramProcesses> programProcesses = new HashSet<ProgramProcesses>();
                    programProcesses.add(programProcess);
                    program.setProgramProcesses(programProcesses);
                    programsDataAccess.updateProgramDetails(program);
                    EntityManager entityManager = EntityManagerUtil.getInstance().currentWfEntityManager();
                    entityManager.merge(program);
                    getProcessInstanceId());
                    userTransaction.commit();
                    asapTransaction.commit();
                    transaction.commit();

                } catch (Exception e) {

                    EntityManagerUtil.getInstance().rollbackWfTransaction();
                    EntityManagerUtil.getInstance().rollbackAsapTransaction();
                    throw e;
                } finally {
                    i
                    EntityManagerUtil.getInstance().closeAsapEntityManager();
                    EntityManagerUtil.getInstance().closeWfEntityManager();
                }
            return programProcess;
        }

    }

}

它失败了我称之为合并功能。错误为

javax.persistence.QueryTimeoutException: ORA-01000: maximum open cursors exceeded.

我尝试关闭结果集但没有运气。有人可以帮我这个。

1 个答案:

答案 0 :(得分:1)

检查Oracle上的打开光标数。例如此查询

SELECT  max(a.value) as highest_open_cur, p.value as max_open_cur FROM v$sesstat a, v$statname b, v$parameter p WHERE  a.statistic# = b.statistic#  and b.name = 'opened cursors current' and p.name= 'open_cursors' group by p.value;

为您提供会话之间的最大打开游标数,以及oracle实例允许的最大打开游标数。也许你需要增加这个数额。