List of usage examples for org.hibernate SessionFactory close
void close() throws HibernateException;
From source file:com.uva.jobportal.dao.CandidateDAOImpl.java
@Override public Candidate editCandidate(Candidate candidate) { try {//from www. j a v a 2 s. co m SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); s.beginTransaction(); s.update(candidate); s.getTransaction().commit(); s.close(); sf.close(); } catch (HibernateException e) { } return candidate; }
From source file:com.uva.jobportal.dao.CandidateDAOImpl.java
@Override public Candidate deleteCandidate(int id) { Candidate candidate = null;//from www .j a v a2s . c om try { SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); s.beginTransaction(); candidate = (Candidate) s.get(Candidate.class, id); s.delete(candidate); s.getTransaction().commit(); s.close(); sf.close(); } catch (HibernateException e) { } return candidate; }
From source file:com.uva.jobportal.dao.CandidateDAOImpl.java
@Override public List<Candidate> listCandidate() { try {/*from www .j av a 2 s .c o m*/ List<Candidate> candidates; SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); Criteria criteria = s.createCriteria(Candidate.class); candidates = (List<Candidate>) criteria.list(); s.close(); sf.close(); return candidates; } catch (HibernateException e) { e.printStackTrace(); return null; } }
From source file:com.uva.jobportal.dao.CandidateDAOImpl.java
@Override public boolean addCandidate(Candidate candidate) { try {// w w w . ja va2 s.c o m SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); Profile profile = new Profile(); profile.setCreated(new Date()); profile.setModified(new Date()); s.beginTransaction(); s.save(candidate); profile.setCandidateId(candidate.getId());// Get candidate id saved s.save(profile); s.getTransaction().commit(); s.close(); sf.close(); return true; } catch (HibernateException e) { return false; } }
From source file:com.uva.jobportal.dao.CandidateDAOImpl.java
@Override public Candidate findById(int id) { Candidate candidate = null;/*from w ww . ja va 2 s. c om*/ try { SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); candidate = (Candidate) s.get(Candidate.class, id); s.close(); sf.close(); } catch (HibernateException e) { } return candidate; }
From source file:com.uva.jobportal.dao.CandidateDAOImpl.java
@Override public boolean existCandidateByUserName(String string) { try {/*from ww w . j a v a2 s. c o m*/ Candidate candidate; SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); candidate = (Candidate) s.get(Candidate.class, string); s.close(); sf.close(); if (candidate == null) { return true; } else { return false; } } catch (HibernateException e) { return false; } }
From source file:com.uva.jobportal.dao.CompanyDAOImpl.java
@Override public Company findById(int id) { Company company = null;/*from w ww.ja va2 s .c o m*/ try { SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); company = (Company) s.get(Company.class, id); s.close(); sf.close(); } catch (HibernateException e) { } return company; }
From source file:com.uva.jobportal.dao.CompanyDAOImpl.java
@Override public List<Company> listCompany() { try {// ww w . j a va2 s. c o m List<Company> listCompany; SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); Criteria criteria = s.createCriteria(Company.class); listCompany = (List<Company>) criteria.list(); s.close(); sf.close(); return listCompany; } catch (HibernateException e) { return null; } }
From source file:com.uva.jobportal.dao.CompanyDAOImpl.java
@Override public boolean addCompany(Company company) { try {/*from w ww . ja v a 2 s . c o m*/ SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); s.beginTransaction(); s.save(company); s.getTransaction().commit(); s.close(); sf.close(); return true; } catch (HibernateException e) { return false; } }
From source file:com.uva.jobportal.dao.CompanyDAOImpl.java
@Override public Company deleteCompany(int id) { try {/*from w w w . j av a2 s . c o m*/ Company company; SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); s.beginTransaction(); company = (Company) s.get(Company.class, id); s.delete(company); s.getTransaction().commit(); s.close(); sf.close(); return company; } catch (HibernateException e) { return null; } }