Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. package com.example.demo;
  2.  
  3. import org.springframework.dao.DataAccessException;
  4. import org.springframework.stereotype.Repository;
  5.  
  6. import javax.persistence.EntityManager;
  7. import javax.persistence.PersistenceContext;
  8. import javax.persistence.TypedQuery;
  9. import javax.transaction.Transactional;
  10. import java.util.List;
  11.  
  12. @Repository
  13. public class ItemRepository {
  14.  
  15. @PersistenceContext
  16. protected EntityManager entityManager;
  17.  
  18. public long getItemCount() throws DataAccessException {
  19. String jpql = "";
  20. TypedQuery<Long> query = entityManager.createQuery(jpql, Long.class);
  21. return query.getSingleResult();
  22. }
  23.  
  24. public Item getItem(long itemId) {
  25. return entityManager.find(Item.class, itemId);
  26. }
  27.  
  28. public List<Item> getItems() {
  29. String jpql = "select i from Items i";
  30. TypedQuery<Item> query = entityManager.createQuery(jpql, Item.class);
  31. }
  32.  
  33. @Transactional
  34. public void insertItem(Item item) {
  35.  
  36. }
  37.  
  38. @Transactional
  39. public void updateItem(Item item) {
  40.  
  41. }
  42.  
  43. @Transactional
  44. public void deleteItem(Item item) {
  45.  
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement