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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -