Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 21st, 2012  |  syntax: None  |  size: 0.59 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Spring and Hibernate configuration
  2. @Service
  3. public class UserServiceImpl implements UserService {
  4.  
  5.  
  6. private SessionFactory sessionFactory;
  7.  
  8. public UserServiceImpl() {
  9.     sessionFactory = new Configuration().configure().buildSessionFactory();
  10.  
  11. }
  12.  
  13.  
  14. @Override
  15. public Collection<Person> getAllUsers() {
  16.     Collection<Person> peoples = new ArrayList<Person>();
  17.     Session session = sessionFactory.getCurrentSession();
  18.     session.beginTransaction();
  19.     Query query = session.createQuery("from Person").setMaxResults(500);
  20.     peoples.addAll(query.list());
  21.     session.close();
  22.     return peoples;
  23. }
  24. }