package heroku.template.service;

import heroku.template.model.Person;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;

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

@Service
public class PersonServiceImpl implements PersonService {

    @PersistenceContext
    EntityManager em;
        
    @Transactional
    public void addPerson(Person person) {
    	em.persist(person);
    }

    @Transactional
    public List<Person> listPeople() {
    	CriteriaQuery<Person> c = em.getCriteriaBuilder().createQuery(Person.class);
        Root<Person> p = c.from(Person.class);
        return em.createQuery(c).getResultList();
    }

    @Transactional
    public void removePerson(Integer id) {
		Person person = (Person) em.find(Person.class, id);
		if (null != person) {
			em.remove(person);
		}
    }
    
}

@@ -68,30 +68,118 @@
 on;%0A
-%0A
 import 
-java.util.List
+org.springframework.stereotype.Service;%0Aimport org.springframework.transaction.annotation.Transactional
 ;%0A%0Ai
@@ -326,148 +326,18 @@
 java
-x.persistence.criteria.Root;%0A%0Aimport org.springframework.stereotype.Service;%0Aimport org.springframework.transaction.annotation.Transactional
+.util.List
 ;%0A%0A@
@@ -703,25 +703,8 @@
     
- Root%3CPerson%3E p =
  c.f
@@ -841,16 +841,16 @@
 r id) %7B%0A
+
 %09%09Person
@@ -862,17 +862,8 @@
 on =
- (Person)
  em.

Remove unnecessary assignment and cast