List of usage examples for org.hibernate Session persist
void persist(Object object);
From source file:com.roic.projectd.dao.ValorDao.java
public void save(Valor datos) { Session session = this.sessionFactory.openSession(); session.persist(datos); }
From source file:com.sapuraglobal.hrms.ejb.AuditBean.java
@Override public void log(String descr, UserDTO author) { AuditDTO audit = create(descr, author); java.util.Date current = new java.util.Date(); audit.setCreated(current);/*from w w w .j a va 2 s .c om*/ audit.setModified(current); Session session = null; Transaction txn = null; try { session = DaoDelegate.getInstance().create(); txn = session.beginTransaction(); session.persist(audit); txn.commit(); } catch (Exception ex) { txn.rollback(); ex.printStackTrace(); } finally { DaoDelegate.getInstance().close(session); } }
From source file:com.sapuraglobal.hrms.ejb.DeptBean.java
@Override public void addDept(DeptDTO deptDTO) { java.util.Date current = new java.util.Date(); deptDTO.setCreated(current);// w ww. java 2s. c o m deptDTO.setModified(current); Session session = null; Transaction txn = null; try { session = DaoDelegate.getInstance().create(); txn = session.beginTransaction(); session.persist(deptDTO); txn.commit(); if (getAuthor() != null) { String descr = "Department:Add Department: " + deptDTO.getDescription(); auditBean.log(descr, getAuthor()); } } catch (Exception ex) { if (txn != null) { txn.rollback(); } ex.printStackTrace(); } finally { DaoDelegate.getInstance().close(session); } }
From source file:com.sapuraglobal.hrms.ejb.DeptBean.java
@Override public void assignEmployee(UserDTO userDTO, DeptDTO deptDTO) { java.util.Date current = new java.util.Date(); Session session = null; Transaction txn = null;//from w ww . j a v a2 s . co m try { session = DaoDelegate.getInstance().create(); txn = session.beginTransaction(); UserDeptDTO userDept = new UserDeptDTO(); if (userDTO.isIsManager()) { userDept.setManager("Y"); } userDept.setCreated(current); userDept.setModified(current); userDept.setDept(deptDTO); userDept.setUser(userDTO); session.persist(userDept); txn.commit(); } catch (Exception ex) { if (txn != null) { txn.rollback(); } ex.printStackTrace(); } finally { DaoDelegate.getInstance().close(session); } }
From source file:com.sapuraglobal.hrms.ejb.LeaveBean.java
@Override public void saveLeaveSetting(LeaveTypeDTO leaveType) { java.util.Date current = new java.util.Date(); Session session = null; Transaction txn = null;// w w w . j a va2s .c o m leaveType.setCreated(current); leaveType.setModified(current); try { session = DaoDelegate.getInstance().create(); txn = session.beginTransaction(); session.persist(leaveType); txn.commit(); } catch (Exception ex) { if (txn != null) { txn.rollback(); } ex.printStackTrace(); } finally { DaoDelegate.getInstance().close(session); } }
From source file:com.sapuraglobal.hrms.ejb.LeaveBean.java
@Override public void applyLeave(LeaveTxnDTO leaveTxn) { Session session = null; Transaction txn = null;/*w w w .j a v a2s. co m*/ java.util.Date current = new java.util.Date(); try { session = DaoDelegate.getInstance().create(); txn = session.beginTransaction(); leaveTxn.setCreated(current); leaveTxn.setModified(current); session.persist(leaveTxn); txn.commit(); } catch (Exception ex) { ex.printStackTrace(); if (txn != null) { txn.rollback(); } } finally { DaoDelegate.getInstance().close(session); } }
From source file:com.sapuraglobal.hrms.ejb.LeaveBean.java
@Override public void addLeaveEnt(LeaveEntDTO leaveEnt) { Session session = null; java.util.Date current = new java.util.Date(); Transaction txn = null;// w w w . j a v a 2s.c om try { session = DaoDelegate.getInstance().create(); txn = session.beginTransaction(); leaveEnt.setCreated(current); leaveEnt.setModified(current); session.persist(leaveEnt); txn.commit(); if (getAuthor() != null) { String descr = "Leave Entitement:Add Leave Entitlement: " + leaveEnt.getLeaveType().getDescription() + " For Employee: " + leaveEnt.getUser().getName(); auditBean.log(descr, getAuthor()); } } catch (Exception ex) { txn.rollback(); ex.printStackTrace(); } finally { DaoDelegate.getInstance().close(session); } }
From source file:com.sapuraglobal.hrms.ejb.TitleBean.java
@Override public void addTitle(TitleDTO title) { java.util.Date current = new java.util.Date(); title.setCreated(current);/*from ww w .jav a 2 s . c om*/ title.setModified(current); Session session = null; Transaction txn = null; try { session = DaoDelegate.getInstance().create(); txn = session.beginTransaction(); session.persist(title); txn.commit(); } catch (Exception ex) { if (txn != null) { txn.rollback(); } ex.printStackTrace(); } finally { DaoDelegate.getInstance().close(session); } }
From source file:com.sapuraglobal.hrms.ejb.UserBean.java
@Override public void createUser(UserDTO user) { java.util.Date current = new java.util.Date(); user.setCreated(current);//from w w w.j a v a 2 s .co m user.setModified(current); Session session = null; Transaction txn = null; try { session = DaoDelegate.getInstance().create(); txn = session.beginTransaction(); user.setDeleted("N"); /* user.getDept().setCreated(current); user.getDept().setModified(current); user.getRole().setCreated(current); user.getRole().setModified(current); user.getLeaveEnt().get(0).setCreated(current); user.getLeaveEnt().get(0).setModified(current); */ session.persist(user); //deptBean.addEmployees(userList, dept); txn.commit(); //audit log if (getAuthor() != null) { String descr = "Employee:Add Employee: " + user.getName(); //auditLog(descr, user.getAuthor()); auditBean.log(descr, getAuthor()); } } catch (Exception ex) { txn.rollback(); ex.printStackTrace(); } finally { DaoDelegate.getInstance().close(session); } }
From source file:com.sapuraglobal.hrms.ejb.UserBean.java
@Override public void assignRole(UserDTO userDto, RoleDTO roleDto) { java.util.Date current = new java.util.Date(); UserRoleDTO userRole = new UserRoleDTO(); userRole.setCreated(current);//w ww. j av a 2s .c o m userRole.setModified(current); Session session = null; Transaction txn = null; try { session = DaoDelegate.getInstance().create(); txn = session.beginTransaction(); userRole.setUser(userDto); userRole.setRole(roleDto); session.persist(userRole); //deptBean.addEmployees(userList, dept); txn.commit(); } catch (Exception ex) { txn.rollback(); ex.printStackTrace(); } finally { DaoDelegate.getInstance().close(session); } }