Transaction tx = null;
session = getSession();
tx = session.beginTransaction();
//SbiEventsLog hibEventLog = toSbiEventsLog(aSession, eventLog);
SbiEventsLog hibEventLog = new SbiEventsLog();
//hibEventLog.setId(eventLog.getId());
hibEventLog.setUser(eventLog.getUser());
hibEventLog.setDate(eventLog.getDate());
hibEventLog.setDesc(eventLog.getDesc());
hibEventLog.setParams(eventLog.getParams());
hibEventLog.setHandlerClass(eventLog.getHandler());
session.save(hibEventLog);
Set hibEventRoles = new HashSet();
List roles = eventLog.getRoles();
Iterator rolesIt = roles.iterator();
while (rolesIt.hasNext()) {
String roleName = (String) rolesIt.next();
/*String hql = "from SbiExtRoles as roles " +
"where roles.name = '" + roleName + "'";*/
String hql = "from SbiExtRoles as roles " +
"where roles.name = ?";
Query hqlQuery = session.createQuery(hql);
hqlQuery.setString(0, roleName);
SbiExtRoles aHibRole = (SbiExtRoles) hqlQuery.uniqueResult();
if (aHibRole == null) {
logger.error("Role with name = '" + roleName + "' does not exist!!");
continue;
}
SbiEventRoleId eventRoleId = new SbiEventRoleId();
eventRoleId.setEvent(hibEventLog);
eventRoleId.setRole(aHibRole);
SbiEventRole aSbiEventRole = new SbiEventRole(eventRoleId);
session.save(aSbiEventRole);
hibEventRoles.add(aSbiEventRole);
}
hibEventLog.setRoles(hibEventRoles);
tx.commit();
logger.debug("OUT");
return hibEventLog.getId();
}