Reputation: 43
Employee table have id, cmpId, name, designation, type
@Query("select emp from Employee emp where emp.cmpId= :cmpId")
List<Employee> findById(@Param("cmpId") long cmpId);
here it will receive all the data from the employee table.
Now I want to retrieve the data id,name and designation as from the DB and for the type it should be always "PERMANENT" even if the value in the DB is any.
How to do this only with the query ?
NOTE: I cannot use the POJO getter to set the value as default value.
Upvotes: 0
Views: 134
Reputation: 561
You can achieve it by doing this,
@Query("select id, name, designation, 'PERMANENT' as type from Employee emp where emp.cmpId= :cmpId")
List<Employee> findById(@Param("cmpId") long cmpId);
This will fix the values for the type column.
Upvotes: 1