최대 절전 모드 세션에서 테이블을 업데이트하려고 시도하고 최대 절전 모드 테이블을 다시 패치하여 로컬 데이터 테이블을 새로 고칩니다. 업데이트를하지 않으면 문제없이 로컬 데이터 테이블을 새로 고칠 수는 있지만 업데이트를 추가하면 서버 로그에 다음 오류가 표시됩니다.왜 내 종은 가까이 간다?
심각도 : org.hibernate.SessionException : 세션이 다음과 같습니다. 닫은!
누구나 내가 뭘 잘못하고 무엇을 할 수있는 문제에 대한 제안을 줄 수 있습니까?
감사합니다.
다음은 업데이트를 수행하는 코드입니다. 예외가 발생하지 않고 테이블의 업데이트 및 커밋을 나타내는 return stat 값 1을 얻었 기 때문에 올바르게 작동하는 것 같습니다.
public int updatePolygonGroupAtrributes(long id, String groupName, String color, long ownerId, int updtUserId)
{
int stat = 0;
TbPolygonGroup polyGroup = null;
TbCustAccount custAcct = null;
TbUser user = null;
try
{
org.hibernate.Transaction tx = session.beginTransaction();
polyGroup = (TbPolygonGroup)session.get(TbPolygonGroup.class, id);
polyGroup.setVcPolygonGroup(groupName);
polyGroup.setVcColor(color);
custAcct = (TbCustAccount)session.get(TbCustAccount.class, ownerId);
System.out.println("<DbHelper.updatePolygonGroupAtrributes> ownerId = "+custAcct.getBiAccountId()+", Name = "+custAcct.getVcCustAccountName());
polyGroup.setTbCustAccount(custAcct);
polyGroup.setDtUpdTime(new Date());
user = (TbUser)session.get(TbUser.class, updtUserId);
System.out.println("<DbHelper.updatePolygonGroupAtrributes> update User Id = "+user.getIuserId()+", Name = "+user.getVcUserFirstName()+" "+user.getVcUserLastName());
polyGroup.setTbUser(user);
try
{
session.update(polyGroup);
tx.commit();
stat = 1;
}
catch(Exception e)
{
tx.rollback();
e.printStackTrace();
status = e.getMessage();
stat = -1;
}
}
catch(Exception ex)
{
ex.printStackTrace();
status = ex.getMessage();
stat = -1;
}
return stat;
}
내 응용 프로그램에서 업데이트를 호출하는 코드는 다음과 같습니다 (내가하는 일의 흐름을 보여주는 것 외에는별로 관련이 없음). 여기
public void polyGroupUpdateAction()
{
int changed = 0;
String clr = "#"+polyColor;
long ownId = sb1.getLong(selectedPolyOwner, 0);
long groupId = selectedPolygonGroup.getBiPolygonGroupId();
int updUserId = sb1.getLoginUserId();
int retVal = dbHelper.updatePolygonGroupAtrributes(groupId, polyName, clr, ownId, updUserId);
if(retVal < 0)
{
sb1.setMessage("Error updating Polygon Group: "+dbHelper.getStatus());
return;
}
System.out.println("---------<DeviceSessionBean.polyGroupUpdateAction> Return value = "+retVal);
sb1.setMessage("Polygon Group has been updated.");
fillPolyGroupList();
return;
}
는 (오류가 발생한 경우 방송) 나는 내 로컬 테이블을 보충 관련 코드 여기
public void fillPolyGroupList()
{
System.out.println("<DeviceSessionBean.fillPolyGroupList> Entering ... ");
tbPolygonGroupList = dbHelper.getPolygonGroup();
System.out.println("<DeviceSessionBean.fillPolyGroupList> After reloading polygon group list ... ");
polygonGroupDataModel = new PolygonGroupDataModel(tbPolygonGroupList);
}
업데이트가 성공적으로 반환을 보여줍니다 세션 로그입니다 만, 오류 때 제공 fillPolyGroupList()에서 데이터 테이블을 다시 읽으려고 시도합니다. 당신이 세션에서 트랜잭션을 커밋 할 때
INFO: <DbHelper.updatePolygonGroupAtrributes> ownerId = 74, Name = TransCore - David Kerr
INFO: <DbHelper.updatePolygonGroupAtrributes> update User Id = 2, Name = Transcore System
INFO: ---------<DeviceSessionBean.polyGroupUpdateAction> Return value = 1
INFO: <DeviceSessionBean.fillPolyGroupList> Entering ...
SEVERE: org.hibernate.SessionException: Session is closed!
at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1319)
.....
at java.lang.Thread.run(Thread.java:662)
INFO: <DeviceSessionBean.fillPolyGroupList> After reloading polygon group list ...
WARNING: #{deviceSessionBean.polyGroupUpdateAction}: java.lang.NullPointerException
javax.faces.FacesException: #{deviceSessionBean.polyGroupUpdateAction}: java.lang.NullPointerException
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
....
Btw wtf는 dbHelper입니까? 우리는 현재 dao를 가지고 있습니다. –
저는 최대 절전 모드에 익숙하지 않습니다. 그리고 이것을 netbeans에 대한 최대 절전 모드 튜토리얼에서 보았습니다. 또한 당신이 참조한 페이지를 보았고 업데이트를하지 않는 데이터를 가져 오는 데 필요한 50 가지 이상의 모든 기능을 다시 작성하지 않아도되기를 바랬습니다. – Burferd