我有下面的查询,以获取一些数据有关两个实体在同一时间,我收到了一个错误。
@Query(value = "select new base.models.HRTableEntity( yr.user.gid, yr.user.id, yr.user.lastName || ' ' || yr.user.firstName, yr.user.position, yr.user.created,yr.genericField1,yr.genericField2) from YearlyReview yr where yr.year = :yr and yr.user.realDepartment = :dep and yr.user.city = :ct",
countQuery = "select count(yr.id) from YearlyReview yr where yr.year = :yr and yr.user.realDepartment = :dep and yr.user.city = :ct",
nativeQuery = false)
Page<HRTableEntity> getAllTableEntity(Pageable pageRequest, @Param("yr") int year, @Param("dep") String department, @Param("ct") String location);
我使用默认Sort(gid: ASC
)调用此函数,并收到以下错误
org.hibernate.QueryException: could not resolve property: gid of: base.entities.YearlyReview
存储库接口:
public interface PageableYearlyReview extends CrudRepository<YearlyReview, UUID>
年度考核有一个ApplicationUser类型的成员(用户),我想将信息从yr.user.gid放入HRTableEntry.gid的DTO中。
什么是正确的方法呢?
EDIT:函数调用:
crunRepoYearTable.getAllTableEntity(PageRequest.of(pageNo - 1, pageSize, sort), year, realDepartment, user.getCity())
分类建筑物
sortDir.equalsIgnoreCase(Sort.Direction.ASC.name()) ? Sort.by(sortedField).ascending() : Sort.by(sortedField).descending();
实体结构:
public class YearlyReview {
@Id
private UUID id;
private int year;
@OneToOne
private ApplicationUser user;
....
}
public class ApplicationUser {
@Id
private String id;
private String gid;
.....
}
1条答案
按热度按时间c6ubokkw1#
问题已解决:
对于按gid排序,需要从前端发送,如
user.gid
。用户需要参考AppUser和gid来访问信息。并更改界面,如public interface PageableYearlyReview extends CrudRepository<ApplicationUser, String>