Advertisement
Guest User

Untitled

a guest
Aug 1st, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. public static List<User> searchAllUsers(String searchby, String search) {
  2. Session session = getSessionFactory().getCurrentSession();
  3. session.beginTransaction();
  4. List<User> result = session.createQuery("from User where "+searchby+"='"+search+"'").list();
  5. session.getTransaction().commit();
  6. return result;
  7. }
  8.  
  9. public static User searchLogin(String username, String password) {
  10. Session session = getSessionFactory().getCurrentSession();
  11. session.beginTransaction();
  12. List<User> result = session.createQuery("from User where username='"+username+"' and password='"+password+"'").list();
  13. session.getTransaction().commit();
  14. return (result.size() == 0) ? null : result.get(0);
  15. }
  16.  
  17. Session session = getSessionFactory().getCurrentSession();
  18. session.beginTransaction();
  19. // operation
  20. session.getTransaction().commit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement