Transaction tx = null;
try {
aSession = getSession();
tx = aSession.beginTransaction();
SbiOrgUnitNodes hibNode = new SbiOrgUnitNodes();
Query hibQuery = aSession.createQuery(" from SbiOrgUnitHierarchies s where s.id = ? ");
hibQuery.setInteger(0, aNode.getHierarchy().getId());
SbiOrgUnitHierarchies hierarchy = (SbiOrgUnitHierarchies) hibQuery.uniqueResult();
hibNode.setSbiOrgUnitHierarchies(hierarchy);
hibNode.setPath(aNode.getPath());
hibQuery = aSession.createQuery(" from SbiOrgUnit s where s.id = ? ");
hibQuery.setInteger(0, aNode.getOu().getId());
SbiOrgUnit ou = (SbiOrgUnit) hibQuery.uniqueResult();
hibNode.setSbiOrgUnit(ou);
if (aNode.getParentNodeId() != null) {
hibQuery = aSession.createQuery(" from SbiOrgUnitNodes s where s.nodeId = ? ");
hibQuery.setInteger(0, aNode.getParentNodeId());
SbiOrgUnitNodes parentNode = (SbiOrgUnitNodes) hibQuery.uniqueResult();
hibNode.setSbiOrgUnitNodes(parentNode);
}
updateSbiCommonInfo4Insert(hibNode);
aSession.save(hibNode);
tx.commit();