List of usage examples for org.hibernate SessionFactory close
void close() throws HibernateException;
From source file:com.uva.jobportal.dao.CompanyDAOImpl.java
@Override public Company editCompany(Company company) { try {/*from w w w . ja v a 2s. co m*/ SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); s.beginTransaction(); s.update(company); s.getTransaction().commit(); s.close(); sf.close(); } catch (HibernateException e) { } return company; }
From source file:com.uva.jobportal.dao.InscriptionDAOImpl.java
@Override public Inscription findById(int id) { Inscription inscription = null;/*from ww w . j a v a2s. c o m*/ try { SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); inscription = (Inscription) s.get(Inscription.class, id); s.close(); sf.close(); } catch (HibernateException e) { } return inscription; }
From source file:com.uva.jobportal.dao.InscriptionDAOImpl.java
@Override public boolean updateInscriptionStatus(Inscription inscription) { try {/*w w w . j av a 2 s.co m*/ SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); s.beginTransaction(); s.update(inscription); s.getTransaction().commit(); s.close(); sf.close(); } catch (HibernateException e) { return false; } return true; }
From source file:com.uva.jobportal.dao.InscriptionDAOImpl.java
@Override public void addInscription(Inscription inscription) { SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession();/* w w w. j av a 2s . c om*/ s.beginTransaction(); s.save(inscription); s.getTransaction().commit(); s.close(); sf.close(); }
From source file:com.uva.jobportal.dao.InscriptionDAOImpl.java
@Override public List<Inscription> listInscriptionByCandidateId(int id) { List<Inscription> inscription; SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession();//from w w w .java 2 s . c o m Criteria criteria = s.createCriteria(Inscription.class).add(Restrictions.eq("candidateId", id)); inscription = (List<Inscription>) criteria.list(); s.close(); sf.close(); return inscription; }
From source file:com.uva.jobportal.dao.InscriptionDAOImpl.java
@Override public List<Inscription> listInscriptionByJobId(int id) { List<Inscription> inscription; SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession();//from ww w.j a v a 2 s .co m Criteria criteria = s.createCriteria(Inscription.class).add(Restrictions.eq("jobId", id)); inscription = (List<Inscription>) criteria.list(); s.close(); sf.close(); return inscription; }
From source file:com.uva.jobportal.dao.InscriptionDAOImpl.java
@Override public boolean findByCandidateIdAndJobId(int candidateId, int jobId) { try {//from ww w .j ava 2 s . com Inscription inscription; SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); s.beginTransaction(); Criteria criteria = s.createCriteria(Inscription.class).add(Restrictions.eq("candidateId", candidateId)) .add(Restrictions.eq("jobId", jobId)); inscription = (Inscription) criteria.uniqueResult(); s.getTransaction().commit(); s.close(); sf.close(); if (inscription.getId() == null) { return false; } else { return true; } } catch (Exception e) { return false; } }
From source file:com.uva.jobportal.dao.JobDAOImpl.java
@Override public List<Job> searchJobByAll(String text, String training, String experience, String languages) { try {//from w w w .j av a2 s . c o m List<Job> jobs; SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); s.beginTransaction(); Criterion criterionTitle = Restrictions.like("title", "%" + text + "%"); Criterion criterionDescription = Restrictions.like("description", "%" + text + "%"); Criterion criterionTitleOrDescription = Restrictions.or(criterionTitle, criterionDescription); Criterion criterionTraining = Restrictions.like("training", "%" + training + "%"); Criterion criterionExperience = Restrictions.like("experience", "%" + experience + "%"); Criterion criterionLanguages = Restrictions.like("languages", "%" + languages + "%"); Criteria criteria = s.createCriteria(Job.class).add(Restrictions.and(criterionTitleOrDescription, criterionTraining, criterionExperience, criterionLanguages)); jobs = (List<Job>) criteria.list(); s.getTransaction().commit(); s.close(); sf.close(); return jobs; } catch (HibernateException e) { return null; } }
From source file:com.uva.jobportal.dao.JobDAOImpl.java
@Override public List<Job> searchJobByText(String text) { try {/*from www .ja va 2s.c o m*/ List<Job> jobs; SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); s.beginTransaction(); Criterion criterionTitle = Restrictions.like("title", "%" + text + "%"); Criterion criterionLocation = Restrictions.like("location", "%" + text + "%"); Criterion criterionDescription = Restrictions.like("description", "%" + text + "%"); Criterion criterionTraining = Restrictions.like("training", "%" + text + "%"); Criterion criterionExperience = Restrictions.like("experience", "%" + text + "%"); Criterion criterionLanguages = Restrictions.like("languages", "%" + text + "%"); Criteria criteria = s.createCriteria(Job.class).add(Restrictions.or(criterionTitle, criterionLocation, criterionDescription, criterionTraining, criterionExperience, criterionLanguages)); jobs = (List<Job>) criteria.list(); s.getTransaction().commit(); s.close(); sf.close(); return jobs; } catch (HibernateException e) { return null; } }
From source file:com.uva.jobportal.dao.JobDAOImpl.java
@Override public List<Job> listJobByCompanyId(int id) { try {//w ww .j a v a2 s .co m List<Job> job = null; SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); Criteria criteria = s.createCriteria(Job.class).add(Restrictions.eq("companyId", id)); job = (List<Job>) criteria.list(); s.close(); sf.close(); return job; } catch (HibernateException e) { e.printStackTrace(); return null; } }