List of usage examples for org.hibernate Session flush
void flush() throws HibernateException;
From source file:com.actop.model.UserManagement.java
public Designation loadDesignation(int id) { Session s = Connection.getSessionFactory().openSession(); Designation d = (Designation) s.load(Designation.class, id); s.flush(); s.close();/*www . ja v a2s.c o m*/ return d; }
From source file:com.actop.model.UserManagement.java
public DepartmentsHasDesignation saveDepartmentHasDesignation(Departments department, Designation designation, Employers emp) {/*from w ww. j a v a 2 s .c o m*/ Session s = Connection.getSessionFactory().openSession(); Criteria c = s.createCriteria(DepartmentsHasDesignation.class); c.add(Restrictions.eq("employers", emp)); DepartmentsHasDesignation departmentsHasDesignation; departmentsHasDesignation = (DepartmentsHasDesignation) c.uniqueResult(); if (departmentsHasDesignation == null) { Transaction t = s.beginTransaction(); departmentsHasDesignation = new DepartmentsHasDesignation(); try { departmentsHasDesignation.setDepartments(department); departmentsHasDesignation.setDesignation(designation); departmentsHasDesignation.setEmployers(emp); s.save(departmentsHasDesignation); } catch (Exception e) { t.rollback(); e.printStackTrace(); } t.commit(); } s.flush(); s.close(); return departmentsHasDesignation; }
From source file:com.actop.model.UserManagement.java
public DepartmentsHasDesignation getDepartmentHasDesignation(Employers emp) { Session s = Connection.getSessionFactory().openSession(); Criteria c = s.createCriteria(DepartmentsHasDesignation.class); c.add(Restrictions.eq("employers", emp)); DepartmentsHasDesignation departmentsHasDesignation; departmentsHasDesignation = (DepartmentsHasDesignation) c.uniqueResult(); s.flush(); s.close();//from w ww . j a va2s . c om return departmentsHasDesignation; }
From source file:com.actop.model.UserManagement.java
public DepartmentsHasDesignation loadDepartmentsHasDesignation(int id) { Session s = Connection.getSessionFactory().openSession(); DepartmentsHasDesignation dhd = (DepartmentsHasDesignation) s.load(DepartmentsHasDesignation.class, id); s.flush(); s.close();/* ww w .ja v a 2s . co m*/ return dhd; }
From source file:com.actop.model.UserManagement.java
public List<DepartmentsHasDesignation> getDesignationFromDept(Departments dept) { Session s = Connection.getSessionFactory().openSession(); Criteria c = s.createCriteria(DepartmentsHasDesignation.class); c.add(Restrictions.eq("departments", dept)); ArrayList<Designation> designations = new ArrayList<>(); List<DepartmentsHasDesignation> l = c.list(); s.flush(); s.close();// w ww . jav a 2 s.c o m return l; }
From source file:com.actop.model.UserManagement.java
public EmployersHasAllowances saveEmployerHasAllowance(Allowances allowance, Designation designation, Employers emp) {/*w ww.j ava 2s . co m*/ Session s = Connection.getSessionFactory().openSession(); Transaction t = s.beginTransaction(); EmployersHasAllowances eha = new EmployersHasAllowances(); try { eha.setAllowances(allowance); eha.setDesignation(designation); eha.setEmployers(emp); s.save(eha); } catch (Exception e) { t.rollback(); e.printStackTrace(); } t.commit(); s.flush(); s.close(); return eha; }
From source file:com.actop.model.UserManagement.java
public List<EmployersHasAllowances> getEmployerHasAllowances() { Session s = Connection.getSessionFactory().openSession(); Criteria c = s.createCriteria(EmployersHasAllowances.class); List<EmployersHasAllowances> allowanceses = c.list(); s.flush(); s.close();/*from ww w .j av a2s.c o m*/ return allowanceses; }
From source file:com.advdb.footballclub.FootBallClub.java
private void createCompetition(Session session, int length) { Transaction transaction = null;/* w w w . j av a 2s . c o m*/ try { System.out.println("start createCompetition."); transaction = session.beginTransaction(); Calendar date = new GregorianCalendar(); int endYear = date.get(Calendar.YEAR); for (int year = endYear - length; year <= endYear; year++) { for (String competitionName : COMPETITION_NAME_ARR) { int seasonStartYear = year; int seasonEndYear = seasonStartYear + 1; String seasonName = seasonStartYear + "/" + seasonEndYear; DimCompetition d = new DimCompetition(competitionName, seasonName, seasonStartYear, seasonEndYear); session.save(d); } session.flush(); session.clear(); } transaction.commit(); System.out.println("finish createCompetition."); } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } } }
From source file:com.advdb.footballclub.FootBallClub.java
private void createTactic(Session session) { Transaction transaction = null;/*w w w. ja va 2s . com*/ try { System.out.println("start createTactic."); transaction = session.beginTransaction(); for (int i = 0; i < TACTIC_INSTRUCTION_ARR.length; i++) { DimTactic d = new DimTactic(TACTIC_NAME_ARR[i], TACTIC_INSTRUCTION_ARR[i]); session.save(d); } session.flush(); session.clear(); transaction.commit(); System.out.println("finish createTactic."); } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } } }
From source file:com.advdb.footballclub.FootBallClub.java
private void createOpponent(Session session) { Transaction transaction = null;//from w w w. ja v a2 s.c o m try { System.out.println("start createOpponent."); transaction = session.beginTransaction(); Reader in = new FileReader("/Users/apichart/Documents/DW_opponent/DimOpponent-Table 1.csv"); Iterable<CSVRecord> records = CSVFormat.DEFAULT.parse(in); for (CSVRecord record : records) { String longName = record.get(2); String shortName = record.get(3); DimOpponent d = new DimOpponent(longName, shortName); session.save(d); } in.close(); session.flush(); session.clear(); transaction.commit(); System.out.println("finish createOpponent."); } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } } catch (FileNotFoundException ex) { Logger.getLogger(FootBallClub.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(FootBallClub.class.getName()).log(Level.SEVERE, null, ex); } }