List of usage examples for org.hibernate SessionFactory close
void close() throws HibernateException;
From source file:com.uva.jobportal.dao.JobDAOImpl.java
@Override public List<Job> listJobByInscription(List<Inscription> inscription) { try {//ww w . ja v a 2s. 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("jobId", inscription.getClass())); job = (List<Job>) criteria.list(); s.close(); sf.close(); return job; } catch (HibernateException e) { e.printStackTrace(); return null; } }
From source file:com.uva.jobportal.dao.JobDAOImpl.java
@Override public List<Job> listJob() { try {//from ww w.j av a2 s .c o m List<Job> job; SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); Criteria criteria = s.createCriteria(Job.class); job = (List<Job>) criteria.list(); s.close(); sf.close(); return job; } catch (HibernateException e) { return null; } }
From source file:com.uva.jobportal.dao.JobDAOImpl.java
@Override public Job findById(int id) { Job job = null;/*from w ww. ja va 2s . c om*/ try { SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); job = (Job) s.get(Job.class, id); s.close(); sf.close(); } catch (HibernateException e) { } return job; }
From source file:com.uva.jobportal.dao.JobDAOImpl.java
@Override public void addJob(Job job) { try {/* w w w . j a v a2 s . c o m*/ SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); s.beginTransaction(); s.save(job); s.getTransaction().commit(); s.close(); sf.close(); } catch (HibernateException e) { } }
From source file:com.uva.jobportal.dao.JobDAOImpl.java
@Override public Job deleteJob(int id) { try {/* w w w . j a v a2 s . co m*/ Job job; SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); s.beginTransaction(); job = (Job) s.get(Job.class, id); s.delete(job); s.getTransaction().commit(); s.close(); sf.close(); return job; } catch (HibernateException e) { return null; } }
From source file:com.uva.jobportal.dao.JobDAOImpl.java
@Override public Job editJob(Job job) { try {/* w w w.j a v a 2s . co m*/ SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); s.beginTransaction(); s.update(job); s.getTransaction().commit(); s.close(); sf.close(); } catch (HibernateException e) { } return job; }
From source file:com.uva.jobportal.dao.LoginDAOImpl.java
@Override public Candidate findCandidate(String userName, String passWord) { Candidate candidate;/*from w ww . j av a 2 s.c o m*/ SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); Criteria criteria = s.createCriteria(Candidate.class).add(Restrictions.eq("userName", userName)) .add(Restrictions.eq("passWord", passWord)); candidate = (Candidate) criteria.uniqueResult(); s.close(); sf.close(); return candidate; }
From source file:com.uva.jobportal.dao.LoginDAOImpl.java
@Override public Company findCompany(String cif, String passWord) { Company company;// w ww . j a v a 2s . com SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession(); Criteria criteria = s.createCriteria(Company.class).add(Restrictions.eq("cif", cif)) .add(Restrictions.eq("passWord", passWord)); company = (Company) criteria.uniqueResult(); s.close(); sf.close(); return company; }
From source file:com.uva.jobportal.dao.LoginDAOImpl.java
@Override public void updateLastLogin(Candidate candidate, Company company) { if (company == null) { try {/*from w w w .j a v a 2 s . c o 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) { } } if (candidate == null) { try { 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) { } } }
From source file:com.uva.jobportal.dao.ProfileDAOImpl.java
@Override public List<Profile> searchProfileByText(String text) { List<Profile> profiles; SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session s = sf.openSession();// w w w . j a v a 2 s. c o m s.beginTransaction(); Criterion criterionCurriculum = Restrictions.like("curriculum", "%" + text + "%"); Criterion criterionTraining = Restrictions.like("training", "%" + text + "%"); Criterion criterionExperience = Restrictions.like("experience", "%" + text + "%"); Criterion criterionLanguages = Restrictions.like("languages", "%" + text + "%"); Criteria criteria = s.createCriteria(Profile.class).add( Restrictions.or(criterionCurriculum, criterionTraining, criterionExperience, criterionLanguages)); profiles = (List<Profile>) criteria.list(); s.getTransaction().commit(); s.close(); sf.close(); return profiles; }