spring - Projection create new field -
i have class represents user date of birth in 2 separated fields
public class user { private int yearofbirth; private int monthofbirth; }
is possible make projection exports user age? know can concatenate fields using @value.
something this, example:
public class useragedto { private int yearofbirth; private int monthofbirth; public useragedto(int yearofbirth, int monthofbirth) { // constructor implementation... } public int getage() { // age calculation... } } public interface userrepo extends jparepository<user, long> { @query("select new com.example.myapp.dto.useragedto(u.yearofbirth, u.monthofbirth) user u u = ?") useragedto getuseragedto(user user); }
some info
Comments
Post a Comment