Session session = this.getSessionFactory().getCurrentSession();
session.beginTransaction();
// check authority
if (! (authority instanceof DbAuthority)) throw new StoreException(StoreException.KEY_NOTFOUND, "Authority is not from this store.");
// add ref
try {
reattach(session, authority);
((DbAuthority) authority).getRefs().add(ref);
session.flush();
session.getTransaction().commit();
} catch (Exception ex) {
ex.printStackTrace(System.err);
session.getTransaction().rollback();
log.error(ex);
throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot access database.");
}
log.trace("Done.");
}