I'm trying to run JPA Query
on Play Framework 1.2.5 unsuccessfully.
I tried like this:
Query query = JPA.em().createQuery("select * from Book");
List<Book> articles = query.getResultList();
render(articles);
But I get error:
The file /app/controllers/Application.java could not be compiled. Error raised is : Query cannot be resolved to a type
What I gotta do?
You have to import the Query class.
import javax.persistence.Query;
Doesn't your IDE flag such errors? SHouldn't you be able to fix basic compilation errors before using Play and JPA? Start by learning the basics of Java.
Also, select * from Book
is not JPQL. select b from Book b
is.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.