I am trying downloading all records from table in h2 buildin database in playframework. I am facing an error:
[IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: * near line 1, column 8 [SELECT * FROM TABLE]]
Method CODE i class Table:
@Transactional(readOnly=true)
public static Result view() {
Query query = JPA.em().createQuery("SELECT * FROM TABLE");
List<Table> downloaded_from_db = query.getResultList();
System.out.println(downloaded_from_db.getClass());
return ok(view.render("none"));
}
Please help me. I would like to see downloaded records in console in simple view. Please give me some tips or good tutorial.
After changing my class loooks like this:
@Transactional(readOnly=true)
public static Result view() {
List<MedicalIncidents> data = JPA.em()
.createNativeQuery("SELECT * FROM MedicalIncident")
//.createQuery("Select m from MedicalIncident m")
.getResultList();
System.out.println(data);
AND I think it works, cause I have 2 entries in that table in database:
But System.out.println(data) return in plaay console:
[[Ljava.lang.Object;@70a0c9be, [Ljava.lang.Object;@4c1d12b6]
But it should return this object by model name like in example: computer-database-jpa:
[models.Computer@214c6fde, models.Computer@63728eb3, models.Computer@75f6bcc6, models.Computer@19e3a7ab, models.Computer@3114d8d4, models.Computer@4fa75f78, models.Computer@756ce822, models.Computer@40fc4c68, models.Computer@73fc612c, models.Computer@3e4fcb31]
So I think that there is something wrong with it. Please help