Is there any support by JPA to map single values to scalar data types? For example, to map NUM in the following query
SELECT COUNT(*) AS NUM FROM EMPLOYEES
to some variable
int numerOfEmployees
or do I have to use JDBC for such use cases?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, you can return scalar types from JPQL queries
as well as from native SQL queries:
Note that in some cases result type may depend on the database, i.e. it can be something like
BigDecimal.