在已获得JbpmContext实例但未close之前,是否可以用hibernate或ibatis中的DAO?
1、调用ibatis
HashMap mapCond = new HashMap();
mapCond.put("actorId",actorId);
mapCond.put("docId",docId);
mapCond.put("state","等待审批");
List docBorrowList = docBorrowManager.searchDocumentBrrowList(mapCond);
//内部是ibatis来实现的
public List select(HashMap mapCond) {
return (List)getSqlMapClientTemplate().queryForList("selectDocBorrow", mapCond);
}
2、调用hibernate
List docBorrowList = docBorrowManager.searchDocumentBrrowList(actorId,docId,"等待审批");
//内部是hibernate实现
@Override
public List searchDocumentBrrowList(String actorId, long docId, String state) {
String hql = "select dw from DocBorrowInfo dw where dw.actorId = '"+actorId+"' and dw.docId="+docId+" and dw.state = '"+state+"'";
return this.getHibernateTemplate().find(hql);
}
前这两种一运行到这句就无法debug下去,下一步调式按钮变为灰色,点击运行也无法执行下去。
3、调用jbpmContext
List docBorrowList = jbpmContext.getSession().createQuery("from DocBorrowInfo where docId="+docId+" and actorId='"+actorId+"' and state='等待审批'").list();
而调用这种方式则没有问题,可我程序里其他地方也调用了DAO,如
/**
* 已查看确认信息结束流程
* @return
*/
public String haveGetConfirmMessage(){
String processInstanceId = this.getRequest().getParameter("processinstanceId");
String docborrowId = this.getRequest().getParameter("docborrowId");
try{
jbpmContext = jbpmConfiguration.createJbpmContext();
long id = 0;
if(null!=docborrowId&&!"".equals(docborrowId)){
id = Long.parseLong(docborrowId);
}
DocBorrowInfo documentBrrow = docBorrowManager.getDocumentBrrow(id);
//结束流程实例
String name = jbpmDelegate.nextStep(jbpmContext, Long.parseLong(processInstanceId),this.getWebUser().getUser().getName(), "结束授权");
if("结束".equalsIgnoreCase(name)){
//设置状态为“结束”
documentBrrow.setState(DocBorrowInfo.ENDSTATE);
jbpmContext.getSession().update(documentBrrow);
}
}finally{
jbpmContext.close();
}
return this.SUCCESS;
}
其中的 DocBorrowInfo documentBrrow = docBorrowManager.getDocumentBrrow(id);也是调用了hibernate的DAO中的方法
public DocBorrowInfo getDocumentBrrow(long id){
DocBorrowInfo documentBrrow = (DocBorrowInfo)this.getHibernateTemplate().load(DocBorrowInfo.class, id);
return documentBrrow;
}
现在还不知到底是何原因?