休止状態のセッションでテーブルを更新しようとしていて、休止状態のテーブルを再フェッチしてローカルデータテーブルを更新しようとしています。私がアップデートをしなければ、問題なくローカルデータテーブルをリフレッシュすることができますが、アップデートを追加するとサーバログに次のエラーが表示されます:私のセッソンはなぜ閉じるのですか?
SEVERE:org.hibernate.SessionException:セッションは閉まっている!
私が間違っていることや問題を解決するために何ができるのか、誰にでも私に示唆を与えることができますか?
ありがとうございました。
ここに更新を行うコードがあります。私は例外を何も得ていないので、テーブルが更新されコミットされたことを示す戻り値の値が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;
}
は、私は(私がやっているものの流れを示すことを除いて、実際には関係ありません)私のapplicatonに更新を呼び出すコードです。
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を持っています –
私は休止状態になっています。これをネットベーンのための休止状態のチュートリアルで見ました。私はあなたが参照したページを見て、更新をしないデータを取得するために持っている50以上の関数をすべて書き直す必要はないと考えていました。 – Burferd