【发布时间】:2020-09-29 11:25:20
【问题描述】:
我有这个域模型:
final class Project {
private final @Id
@With
long projectId;
private final String projectType;
@With
private final ProjectRecipient projectRecipient;
@With
private final Set<PreCalculationCosts> preCalculationCosts;
@With
private final Set<PostCalculationCosts> postCalculationCosts;
}
问题:
当我从CrudRepository 调用findById 方法时,属性projectRecipient 被具体化。
我什至在日志中看到所有发出的 sql 语句都是必需的。
当我使用我自己的Query 时,只有一对多属性正在实现(没有为一对一相关项目接收者发布选择语句):
select p.* from project p
inner join projectrecipient pr on pr.project = p.projectid
where p.projectid = :projectId
编辑
当我调试findById 方法并将此生成的SQL 用作Query 值时,它会以正确的方式实现。问题在于,我的 Project 表有很多列,所以 Query 值字符串在我的 IDE(A) 中是 5 行 ...
另一方面,我不能使用findById 方法,因为我需要一些postgres 特定的similar to 子句...
【问题讨论】:
标签: java spring spring-data one-to-one spring-data-jdbc