class DBPolicyManager extends DBManager<Policy> implements PolicyManager {

    @Override
    public final Policy getDefaultPolicy(final Appraiser appraiser) {
        if (appraiser == null) {
            LOGGER.error("cannot get default policy for null appraiser");
            return null;
        }

        Policy ret = null;
        final SessionFactory factory = getFactory();
        Transaction tx = null;
        Session session = factory.getCurrentSession();
        try {
            tx = session.beginTransaction();
            LOGGER.debug("retrieving policy mapper from db where appraiser = {}",
                    appraiser);
            final Criteria cr = session.createCriteria(PolicyMapper.class)
                    .createAlias("deviceGroup", "group")
                    .add(Restrictions.eq("appraiser", appraiser))
                    .add(Restrictions.eq("group.name", DeviceGroup.DEFAULT_GROUP));
            final PolicyMapper mapper = (PolicyMapper) cr.uniqueResult();
            if (mapper == null) {
                LOGGER.debug("no policy mapper found for appraiser {}",
                        appraiser);
            } else {
                ret = mapper.getPolicy();
            }
            session.getTransaction().commit();
        } catch (Exception e) {
            final String msg = "unable to get default policy";
            LOGGER.error(msg, e);
            if (tx != null) {
                LOGGER.debug("rolling back transaction");
                tx.rollback();
            }
            throw new DBManagerException(msg, e);
        }
        return ret;
    }

    public  DBPolicyManager(final SessionFactory factory);

}