Session session = this.getSessionFactory().getCurrentSession();
session.beginTransaction();
// check subsegment
if (! (subSegment instanceof DbSubSegment)) throw new StoreException(StoreException.KEY_NOTFOUND, "Subsegment is not from this store.");
// get parent authority
DbAuthority parentAuthority;
try {
reattach(session, subSegment);
parentAuthority = ((DbSubSegment)subSegment).getParent();
Hibernate.initialize(parentAuthority);
if (parentAuthority == null) {
throw new StoreException(StoreException.KEY_NOTFOUND, "Parent authority does not exist.");
}
session.getTransaction().commit();
} catch (StoreException ex) {
session.getTransaction().rollback();
log.error(ex);
throw(ex);
} catch (Exception ex) {
session.getTransaction().rollback();
log.error(ex);
throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot access database.");
}
// done
log.trace("Done.");