package controllers;

import models.Person;
import play.data.FormFactory;
import play.db.jpa.JPAApi;
import play.db.jpa.Transactional;
import play.mvc.Controller;
import play.mvc.Result;
import views.html.index;

import javax.inject.Inject;
import java.util.List;

import static play.libs.Json.toJson;

public class PersonController extends Controller {

    private final FormFactory formFactory;

    private final JPAApi jpaApi;

    @Inject
    public PersonController(FormFactory formFactory, JPAApi jpaApi) {
        this.formFactory = formFactory;
        this.jpaApi = jpaApi;
    }

    public Result index() {
        return ok(index.render());
    }

    @Transactional
    public Result addPerson() {
        Person person = formFactory.form(Person.class).bindFromRequest().get();
        jpaApi.em().persist(person);
        return redirect(routes.PersonController.index());
    }

    @Transactional(readOnly = true)
    public Result getPersons() {
        //noinspection unchecked
        List<Person> persons = (List<Person>) jpaApi.em().createQuery("select p from Person p").getResultList();
        return ok(toJson(persons));
    }
}

@@ -961,41 +961,8 @@
 ) %7B%0A
-        //noinspection unchecked%0A
     
@@ -991,23 +991,8 @@
 ns =
- (List%3CPerson%3E)
  jpa
@@ -1036,16 +1036,30 @@
 erson p%22
+, Person.class
 ).getRes

Remove casting in query (#6290)