Hi all,

I'm helping Mitesh implementing the persistence layer abstraction
for roller.

I'm wondering, if strategy specific exceptions should be wrapped into
RollerExceptions by the strategy implementation. All persistence
layers throw RuntimeExceptions: PersistenceExceptions for JPA,
JDOExceptions for JDO or HibernateExceptions for Hibernate.

Should strategy specific RuntimeExceptions be wrapped into checked
RollerExceptions? E.g. in JPAPersistenceStrategy, we could implement
something like:

  public void flush() throws RollerException {
      try {
          EntityManager em = getEntityManager(false);
          if (isTransactionActive(em)) {
              em.getTransaction().commit();
          }
          em.close();
      } catch (PersistenceException e) {
          throw new RollerException(e);
      }
  }

Also, should be same be done for other persistence layer related exceptions?
E.g. SQLExceptions or NullPointerExceptions?

Thanks,

-- markus.

Reply via email to