Transaction tx = null;
try {
tmpSession = getSession();
tx = tmpSession.beginTransaction();
SbiMenu hibMenu = (SbiMenu) tmpSession.load(SbiMenu.class, menuID);
Integer oldProg = hibMenu.getProg();
Integer newProg = new Integer(oldProg.intValue() + 1);
String upperMenuHql = "";
Query query = null;
if (hibMenu.getParentId() == null || hibMenu.getParentId().intValue()==0){
//upperMenuHql = "from SbiMenu s where s.prog = " + newProg.toString() +
//" and s.parentId is null ";
upperMenuHql = "from SbiMenu s where s.prog = ? " +
" and (s.parentId is null or s.parentId = 0)";
query = tmpSession.createQuery(upperMenuHql);
query.setInteger(0, newProg.intValue());
}
else {
//upperMenuHql = "from SbiMenu s where s.prog = " + newProg.toString() +
//" and s.parentId = " + hibMenu.getParentId().toString();
upperMenuHql = "from SbiMenu s where s.prog = ? " +
" and s.parentId = ? " ;
query = tmpSession.createQuery(upperMenuHql);
query.setInteger(0, newProg.intValue());
query.setInteger(1, hibMenu.getParentId().intValue());
}
//Query query = tmpSession.createQuery(upperMenuHql);
SbiMenu hibUpperMenu = (SbiMenu) query.uniqueResult();
if (hibUpperMenu == null) {
logger.error("The menu with prog [" + newProg + "] does not exist.");
return;
}
hibMenu.setProg(newProg);
hibUpperMenu.setProg(oldProg);
updateSbiCommonInfo4Update(hibMenu);
updateSbiCommonInfo4Update(hibUpperMenu);
tx.commit();
} catch (HibernateException he) {
if (tx != null)