// Query
@NamedQuery(
name = "id_select",
query="SELECT rf.id FROM ReportFavo ASrf WHERErf.report_id=:report_id ANDrf.employee=:employee"
)
// Store query values in variables
int id=em.createNameQuery("id_select", int.class)
.setParameter("report_id", report_id)
.setParameter ("employee", employee_id)
.getSingleResult();
Error Message
HTTP Status 500 - Type specified for TypeQuery [int] is incompatible with query return type [class java.lang.Integer]
If you are using a JPA-based framework (such as Hibernate), you can show it in the body or tag so that people who are familiar with it can easily find it.
Error Message
Type specified for TypedQuery [int] is incompatible with query return type [class java.lang.Integer]
That means
The type (int) specified in the query with type is incompatible with the query return type (Integer)
This means that you should first try to modify it (the type specified in the type query).
Use intid=em.createNameQuery("id_select", Integer.class)//<-`Integer`
.setParameter("report_id", report_id)
.setParameter ("employee", employee_id)
.getSingleResult();
© 2024 OneMinuteCode. All rights reserved.