評(píng)論
下面是轉(zhuǎn)自【http://www.aygfsteel.com/i369/articles/240039.html】
一般這個(gè)錯(cuò)誤是事務(wù)引起的,如果確定事務(wù)沒(méi)有問(wèn)題,還是有這個(gè)錯(cuò),可以重寫OpenSessionInViewFilter的2個(gè)方法
在myfaces的wiki里提供了OpenSessionInViewFilter的一個(gè)子類如下:
public class OpenSessionInViewFilter extends org.springframework.orm.hibernate3.support.OpenSessionInViewFilter {
/**
* we do a different flushmode than in the codebase
* here
*/
protected Session getSession(SessionFactory sessionFactory) throws DataAccessResourceFailureException {
Session session = SessionFactoryUtils.getSession(sessionFactory, true);
session.setFlushMode(FlushMode.COMMIT);
return session;
}
/**
* we do an explicit flush here just in case
* we do not have an automated flush
*/
protected void closeSession(Session session, SessionFactory factory) {
session.flush();
super.closeSession(session, factory);
}
}
回復(fù) 更多評(píng)論
一般這個(gè)錯(cuò)誤是事務(wù)引起的,如果確定事務(wù)沒(méi)有問(wèn)題,還是有這個(gè)錯(cuò),可以重寫OpenSessionInViewFilter的2個(gè)方法
在myfaces的wiki里提供了OpenSessionInViewFilter的一個(gè)子類如下:
public class OpenSessionInViewFilter extends org.springframework.orm.hibernate3.support.OpenSessionInViewFilter {
/**
* we do a different flushmode than in the codebase
* here
*/
protected Session getSession(SessionFactory sessionFactory) throws DataAccessResourceFailureException {
Session session = SessionFactoryUtils.getSession(sessionFactory, true);
session.setFlushMode(FlushMode.COMMIT);
return session;
}
/**
* we do an explicit flush here just in case
* we do not have an automated flush
*/
protected void closeSession(Session session, SessionFactory factory) {
session.flush();
super.closeSession(session, factory);
}
}
回復(fù) 更多評(píng)論
只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。 | ||
![]() |
||
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問(wèn)
管理
|
||
相關(guān)文章:
|
||