1
回答
spring data jpa 原生查询
开发十年,就只剩下这套Java开发体系了   
@Query(value = "SELECT act.receiver_id, u.user_name AS receiver_name, u.mobile_phone AS receiver_mobile_phone, act.create_time FROM tta_share_code_activate act LEFT JOIN tta_user u ON u.id = act.receiver_id WHERE act.share_user_id=?1 ORDER BY ?#{#pageable}",
        countQuery = "SELECT count(*) FROM tta_share_code_activate  WHERE share_user_id=?1",
        nativeQuery = true)
 Page<ShareActice> findShareByUser(String shareUserId, Pageable pageable);

其中ShareActive是我自定义的一个类。但是框架无法将查询出的结果转换成ShareActive。应该怎么办才能将字段映射到ShareActive中呢?我发现Page<T>里面的T必须是entity的时候才会转换,但是我字段都是自定义的啊

举报
小安是屌丝
发帖于7天前 1回/33阅
顶部