How to run a JPA request in a gaming platform

I am new to Play, and also to sleep and JPA. I am using MySql DB and JPA I have included

import javax.persistence.Entity; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.Persistence; import javax.persistence.Query; import play.db.jpa.JPA; import play.mvc.Controller; import play.db.jpa.*; 

I have this request

 List languages = FormLanguages.findAll(); render(languages); 

Which works correctly, but I want to select based on id, something like this

"select * from FormLanguages, where id> 10"

When I use it like

 Query query = JPA.em().createQuery("select * from FormLanguages"); List<FormLanguages> articles = query.getResultList(); render(articles); 

Which gives me an IllegalArgumentException error

When using this

 List queryList = FormLanguages.em().createQuery("select * from FormLanguages").getResultList(); render(queryList); 

which gives the same error please help me how to write a query

Also suggest me some sites

+6
source share
1 answer

In your scenario:

 List languages = FormLanguages.find("id > ?",10).fetch(); 

Must work.

This one as well as this one can help you learn the JPA query language. Once you are familiar with them using find , you can run these queries. Or use named queries .

+4
source

Source: https://habr.com/ru/post/893670/


All Articles