【发布时间】:2021-08-19 23:56:13
【问题描述】:
刚刚从 .NET Core 切换到 Spring Boot,在 .NET Core 中,我们可以轻松地将 select 嵌套在 select 中,如下所示:
var result = from c in context.Cars
join br in context.Brands
on c.BrandId equals br.Id
join col in context.Colors
on c.ColorId equals col.Id
select new CarDetailDto
{
Id = c.Id,
BrandName = br.Name,
CarName = c.Name,
ColorName = col.Name,
DailyPrice = c.DailyPrice,
ModelYear = c.ModelYear,
CarImages = (from cimg in context.CarImages
where cimg.CarId == c.Id
select new CarImage
{
Id = cimg.Id,
ImagePath = cimg.ImagePath,
CarId = c.Id,
Date = cimg.Date
}).ToList()
};
我也想在 JPQL 中这样做,但没能解决
【问题讨论】:
-
你到底尝试了什么?
-
我有一个内部有一对多的实体。就像具有工作经验的简历一样,由于无限递归,我必须将其 JsonIgnore,我想将简历信息中的工作经验列表获取到带有 @Query 注释的 DTO 但我无法编写 JPQL 基本上我想将那个 .NET 查询翻译成top to JPQL 查询
标签: java spring hibernate jpql