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

    • Type: Task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1 M4
    • Fix Version/s: 1.2 M1
    • Component/s: Storage
    • Labels:
      None
    • keywords:
      store,DBImprovement,hibernate
    • Similar issues:

      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

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

              Dates

              Created:
              Updated:
              Resolved:
              Date of First Response: