How to get JPA work in Play MVC. I tried a lot of variants. But all unsuccesfull.
public class Application extends Controller {
public static void book() {
EntityManager em = JPA.em();
List<Book> bookList = em.createNativeQuery("select * from book").getResultList();
render( bookList );
}
public static void index() {
render( );
}
}
I got error like this:
A JPA error occurred (The JPA context is not initialized. JPA Entity Manager automatically start when one or more classes annotated with the @javax.persistence.Entity annotation are found in the application.):
Second variant doesnt' work:
@NamedQuery(name = "findFoo", query = "select f from Foo f where f.state in :stateInList")
final Query query = this.entityManager.createNamedQuery("findFoo");
How to get worked with NamedQuery ?? Where to place NamedQuery ??