Criteria criteria = null;
try {
aSession = getSession();
tx = aSession.beginTransaction();
SbiObjMetacontents hibContents = (SbiObjMetacontents) aSession.load(SbiObjMetacontents.class,
new Integer(aObjMetacontent.getObjMetacontentId()));
// update biobject reference
if (hibContents.getSbiObjects().getBiobjId() != aObjMetacontent.getBiobjId()) {
aCriterion = Expression.eq("biobjId", aObjMetacontent.getBiobjId());
criteria = aSession.createCriteria(SbiObjects.class);
criteria.add(aCriterion);
SbiObjects biobj = (SbiObjects) criteria.uniqueResult();
hibContents.setSbiObjects(biobj);
}
// update subobject reference
if (aObjMetacontent.getSubobjId() == null) {
hibContents.setSbiSubObjects(null);
} else {
SbiSubObjects previousSubobject = hibContents.getSbiSubObjects();
if (previousSubobject == null || previousSubobject.getSubObjId() != aObjMetacontent.getSubobjId()) {
aCriterion = Expression.eq("subObjId", aObjMetacontent.getSubobjId());
criteria = aSession.createCriteria(SbiSubObjects.class);
criteria.add(aCriterion);
SbiSubObjects subobj = (SbiSubObjects) criteria.uniqueResult();
hibContents.setSbiSubObjects(subobj);
}
}
updateSbiCommonInfo4Update(hibContents);
// update content
SbiBinContents binaryContent = hibContents.getSbiBinContents();
if (binaryContent == null) {
binaryContent = new SbiBinContents();
binaryContent.setContent(aObjMetacontent.getContent());
} else {
binaryContent.setContent(aObjMetacontent.getContent());
}
updateSbiCommonInfo4Insert(binaryContent);
aSession.save(binaryContent);
hibContents.setSbiBinContents(binaryContent);
// update metadata reference
hibContents.setObjmetaId(aObjMetacontent.getObjmetaId());
// update last change date
hibContents.setLastChangeDate(aObjMetacontent.getLastChangeDate());
tx.commit();
} catch (HibernateException he) {
logger.error("Error while modifing the meta content with id " + ((aObjMetacontent == null)?"":String.valueOf(aObjMetacontent.getObjMetacontentId())), he);
if (tx != null)