package devopsdistilled.operp.server.service.impl;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;

import devopsdistilled.operp.server.model.Item;
import devopsdistilled.operp.server.service.ItemService;

@Repository("ItemService")
public class ItemServiceImpl implements ItemService {

    @PersistenceContext
    private EntityManager em;

    @Override
    public Item createItem(String name) {
	Item item = new Item();
	item.setName("Test Item");
	em.persist(item);
	return item;
    }

}

package devopsdistilled.operp.server.service.impl;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import devopsdistilled.operp.server.model.Item;
import devopsdistilled.operp.server.service.ItemService;

@Repository("ItemService")
@Transactional
public class ItemServiceImpl implements ItemService {

    @PersistenceContext
    private EntityManager em;

    @Override
    public Item createItem(String name) {
	Item item = new Item();
	item.setName("Test Item");
	em.persist(item);
	return item;
    }

}

add @Transactional