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?
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?
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
.