Guest User

Untitled

a guest
Jun 19th, 2019
65
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public List<Client> getClients()
  2. {
  3. List<Client> clist = new ArrayList<Client>();
  4. entityManager =entityManagerFactory.createEntityManager();
  5. try
  6. {
  7. clist = entityManager.createQuery("from Client").getResultList();
  8. return clist;
  9. }
  10. catch (Exception e)
  11. {
  12. }
  13. finally
  14. {
  15. entityManager.close()
  16. }
  17. }
  18.  
  19. @PersistenceContext
  20. private EntityManager entityManager;
  21.  
  22. public List<Client> getClients()
  23. {
  24. List<Client> clist = new ArrayList<Client>();
  25. try
  26. {
  27. clist = entityManager.createQuery("from
  28. Client").getResultList();
  29. return clist;
  30. }
  31. catch (Exception e)
  32. {
  33. LOGGER.error(e.getMessage());
  34. LOGGER.error(e.getStackTrace());
  35.  
  36. return clist;
  37. }
  38. }
  39.  
  40. @Transactional
  41. public void addNotification(Notifications noti)
  42. {
  43.  
  44. try
  45. {
  46. getEntityManager().getTransaction().begin();
  47. getEntityManager().persist(noti);
  48. getEntityManager().getTransaction().commit();
  49.  
  50. // getEntityManager().persist(noti);
  51. }
  52. catch (Exception e)
  53. {
  54. LOGGER.error(e.getMessage());
  55. LOGGER.error(e.getStackTrace());
  56. }
  57. finally
  58. {
  59.  
  60. }
  61. }
RAW Paste Data