Created
October 14, 2014 04:38
-
-
Save gabanox/f3e1917922b0a9aa113d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Contact> findAll() { | |
return sessionFactory.getCurrentSession().createQuery("from Contact c").list(); | |
} | |
public List<Contact> findAllWithDetail() { | |
return sessionFactory.getCurrentSession().getNamedQuery("Contact.findAllWithDetail").list(); | |
} | |
public Contact findById(Long id) { | |
return (Contact) sessionFactory.getCurrentSession(). | |
getNamedQuery("Contact.findById").setParameter("id", id).uniqueResult(); | |
} | |
public Contact save(Contact contact) { | |
sessionFactory.getCurrentSession().saveOrUpdate(contact); | |
log.info("Contact saved with id: " + contact.getId()); | |
return contact; | |
} | |
public void delete(Contact contact) { | |
sessionFactory.getCurrentSession().delete(contact); | |
log.info("Contact deleted with id: " + contact.getId()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment