Description
@see http://www.springframework.org/docs/api/org/springframework/orm/hibernate/HibernateTemplate.html#execute(org.springframework.orm.hibernate.HibernateCallback) for ancestor.
This allow easy to switch our session managment, easy to monitoring this actions (via monitor plugin), and no bother open/close session by hand
Sample use case:
protected List loadAllRCSNodeInfo(XWikiContext context, final long id, boolean bTransaction) throws XWikiException { return (List) executeRead(context, bTransaction, new HibernateCallBack() { public Object doInHibernate(Session session) throws Exception { return session.createCriteria(XWikiRCSNodeInfo.class) .add(Restrictions.eq("id.docId", Long.valueOf(id))) .list(); } }); }