Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class UserDAO {
- private SessionFactory sessionFactory;
- public UserDAO() {
- sessionFactory = HibernateUtil.getSessionFactory();
- }
- /* public void dodajGatunek(Gatunek a) {
- try {
- if (!sessionFactory.getCurrentSession().getTransaction().isActive()) {
- sessionFactory.getCurrentSession().getTransaction().begin();
- }
- sessionFactory.getCurrentSession().save(a);
- sessionFactory.getCurrentSession().getTransaction().commit();
- } catch (Exception e) {
- sessionFactory.getCurrentSession().getTransaction().rollback();
- throw e;
- }
- }*/
- @SuppressWarnings("unchecked")
- public List<User> getUsers(){
- try {
- if(!sessionFactory.getCurrentSession().getTransaction().isActive()) {
- sessionFactory.getCurrentSession().getTransaction().begin();
- }
- return sessionFactory.getCurrentSession().createCriteria(User.class).list();
- }catch(Exception e) {
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement