When using entityManager.createNativeQuery (sql, User.class) this approach, encounter a problem, there is a User entity class, which has a dayTaskNum field indicates the user how many tasks to do that day, the field does not keep notes added @transient library.
sql statement probably select u. *, (select count (id) from t_task t where t.user_id = u.id) as dayTaskNum from t_user. Every time I want to get the user information to the user while the number of tasks to take out the same day, sql statements directly executed without problems, but the value dayTaskNum not injected into the User, the Internet is basically saying you do not specify a generic, direct return List < Object []> manual assignment in this manner, is there then there can be generic alias field injection method?
Original Address: https: //www.oschina.net/question/3102753_2215576