Package org.openbp.server.persistence

Examples of org.openbp.server.persistence.TransactionGuard


   */
  public void deleteObject(final Object o)
    throws PersistenceException
  {
    checkObject(o);
    TransactionGuard tg = new TransactionGuard(this);
    try
    {
      getDataContext().deleteObject(o);
    }
    catch (Exception e)
    {
      tg.doCatch();
      throw createLoggedException(e);
    }
    finally
    {
      tg.doFinally();
    }
  }
View Full Code Here


   * @throws PersistenceException On error
   */
  public int executeUpdateOrDelete(String sql)
    throws PersistenceException
  {
    TransactionGuard tg = new TransactionGuard(this);
    try
    {
      SQLTemplate temp = new SQLTemplate();
      temp.setDefaultTemplate(sql);

      DataMap dataMap = getDataContext().getEntityResolver().getDataMaps().iterator().next();
      temp.setRoot(dataMap);

      int count = 0;
      int [] counts = getDataContext().performNonSelectingQuery(temp);
      if (counts.length > 0)
        count = counts[0];
      return count;
    }
    catch (Exception e)
    {
      tg.doCatch();
      throw createLoggedException(e);
    }
    finally
    {
      tg.doFinally();
    }
  }
View Full Code Here

   * @throws PersistenceException On error
   */
  public Iterator executeSelect(String sql, int maxResults)
    throws PersistenceException
  {
    TransactionGuard tg = new TransactionGuard(this);
    try
    {
      SQLTemplate temp = new SQLTemplate();
      temp.setDefaultTemplate(sql);
      if (maxResults > 0)
      {
        temp.setFetchLimit(maxResults);
      }

      DataMap dataMap = getDataContext().getEntityResolver().getDataMaps().iterator().next();
      temp.setRoot(dataMap);

      Collection result = getDataContext().performQuery(temp);
      return new CayenneIterator(result.iterator());
    }
    catch (Exception e)
    {
      tg.doCatch();
      throw createLoggedException(e);
    }
    finally
    {
      tg.doFinally();
    }
  }
View Full Code Here

TOP

Related Classes of org.openbp.server.persistence.TransactionGuard

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.