Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-1611

Create methods for allow work in hibernate store via callbacks(closures) without open/close connection

    XMLWordPrintable

Details

    • Task
    • Resolution: Fixed
    • Minor
    • 1.2 M1
    • 1.1 M4
    • Storage
    • None
    • store,DBImprovement,hibernate

    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();
                  }
              });
          }
      

      Attachments

        Activity

          People

            amelentev Artem Melentev
            amelentev Artem Melentev
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: