class DBDeviceStateManager extends DBManager<DeviceState> implements DeviceStateManager {

    @Override
    public final boolean deleteState(final Device device, final Class<? extends DeviceState> clazz)
            throws DeviceStateManagerException {
        LOGGER.debug("deleting state for device: {}", device);
        if (device == null) {
            LOGGER.error("null device argument");
            throw new NullPointerException("null device");
        }

        boolean ret = false;
        Transaction tx = null;
        Session session = getFactory().getCurrentSession();
        try {
            LOGGER.debug("retrieving state from db");
            tx = session.beginTransaction();
            final DeviceState state = (DeviceState) session
                    .createCriteria(clazz)
                    .add(Restrictions.eq("device", device)).uniqueResult();
            if (state != null) {
                session.delete(state);
                ret = true;
            }
            tx.commit();
        } catch (Exception e) {
            final String msg = "unable to retrieve object";
            LOGGER.error(msg, e);
            if (tx != null) {
                LOGGER.debug("rolling back transaction");
                tx.rollback();
            }
            throw new DBManagerException(msg, e);
        }
        return ret;
    }

    public  DBDeviceStateManager(final SessionFactory sessionFactory);

}