try {
aSession = getSession();
tx = aSession.beginTransaction();
SbiConfig hibConfig = null;
Integer id = config.getId();
Criterion domainCriterrion = Expression.eq("valueId",config.getValueTypeId());
Criteria domainCriteria = aSession.createCriteria(SbiDomains.class);
domainCriteria.add(domainCriterrion);
SbiDomains hibDomains = (SbiDomains) domainCriteria.uniqueResult();
if(id!=null){
//modification
logger.debug("Update Config");
hibConfig = (SbiConfig) aSession.load(SbiConfig.class, id);
updateSbiCommonInfo4Update(hibConfig);
hibConfig.setLabel(config.getLabel());
hibConfig.setDescription(config.getDescription());
hibConfig.setName(config.getName());
hibConfig.setValueCheck(config.getValueCheck());
hibConfig.setIsActive(config.isActive());
hibConfig.setSbiDomains(hibDomains);
hibConfig.setCategory(config.getCategory());
}
else{
//insertion
logger.debug("Insert new Config");
hibConfig = fromConfig(config);
updateSbiCommonInfo4Insert(hibConfig);
hibConfig.setSbiDomains(hibDomains);
}
Integer newId = (Integer) aSession.save(hibConfig);
tx.commit();