package heroku.template.service;

import heroku.template.model.Person;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.criteria.CriteriaQuery;
import java.util.List;

@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);
        c.from(Person.class);
        return em.createQuery(c).getResultList();
    }

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

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);
		}
    }
    
}

--- 
+++ 
@@ -1,16 +1,13 @@
 package heroku.template.service;
 
 import heroku.template.model.Person;
-
-import java.util.List;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 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;
+import java.util.List;
 
 @Service
 public class PersonServiceImpl implements PersonService {
@@ -26,13 +23,13 @@
     @Transactional
     public List<Person> listPeople() {
     	CriteriaQuery<Person> c = em.getCriteriaBuilder().createQuery(Person.class);
-        Root<Person> p = c.from(Person.class);
+        c.from(Person.class);
         return em.createQuery(c).getResultList();
     }
 
     @Transactional
     public void removePerson(Integer id) {
-		Person person = (Person) em.find(Person.class, id);
+		Person person = em.find(Person.class, id);
 		if (null != person) {
 			em.remove(person);
 		}
Remove unnecessary assignment and cast
