13 |
|
|
14 |
@SuppressWarnings("unchecked") |
@SuppressWarnings("unchecked") |
15 |
public List<Employee> getAll() { |
public List<Employee> getAll() { |
16 |
Session session = HibernateUtil.getSessionFactory().openSession(); |
Session session = HibernateUtil.getSessionFactory().getCurrentSession(); |
17 |
Transaction tx = session.beginTransaction(); // Dummy Transcaction |
Transaction tx = session.beginTransaction(); // Dummy Transcaction |
18 |
|
|
19 |
Criteria c = session.createCriteria(Employee.class); |
Criteria c = session.createCriteria(Employee.class); |
20 |
java.util.List<Employee> list = c.list(); |
java.util.List<Employee> list = c.list(); |
21 |
tx.rollback(); //since no changes was made, just as well rollback |
tx.rollback(); //since no changes was made, just as well rollback |
22 |
session.close(); |
// session.close(); |
23 |
|
|
24 |
return list; |
return list; |
25 |
} |
} |
36 |
//session.close(); |
//session.close(); |
37 |
} |
} |
38 |
public void updateEmployee(Employee emp) { |
public void updateEmployee(Employee emp) { |
39 |
Session session = HibernateUtil.getSessionFactory().openSession(); |
Session session = HibernateUtil.getSessionFactory().getCurrentSession(); |
40 |
|
|
41 |
Transaction tx = session.beginTransaction(); |
Transaction tx = session.beginTransaction(); |
42 |
session.update(emp); |
session.update(emp); |
43 |
tx.commit(); |
tx.commit(); |
44 |
session.close(); |
// session.close(); |
45 |
|
|
46 |
} |
} |
47 |
|
|