Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.demo;
- import org.springframework.dao.DataAccessException;
- import org.springframework.stereotype.Repository;
- import javax.persistence.EntityManager;
- import javax.persistence.PersistenceContext;
- import javax.persistence.TypedQuery;
- import javax.transaction.Transactional;
- import java.util.List;
- @Repository
- public class ItemRepository {
- @PersistenceContext
- protected EntityManager entityManager;
- public long getItemCount() throws DataAccessException {
- String jpql = "";
- TypedQuery<Long> query = entityManager.createQuery(jpql, Long.class);
- return query.getSingleResult();
- }
- public Item getItem(long itemId) {
- return entityManager.find(Item.class, itemId);
- }
- public List<Item> getItems() {
- String jpql = "select i from Items i";
- TypedQuery<Item> query = entityManager.createQuery(jpql, Item.class);
- }
- @Transactional
- public void insertItem(Item item) {
- }
- @Transactional
- public void updateItem(Item item) {
- }
- @Transactional
- public void deleteItem(Item item) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement