@JoinFormula和@OneToMany定义-较差的文档
我有两个有关@JoinFormula和@OneToMany批注的问题:
如何限制带有
@JoinFormula
和@OneToMany
注释的结果数?如何定义
id
表达式中author = id
所指的Author.id
?Author {
@Id
private Long id;
@OneToMany
@JoinFormula(value = "SELECT a FROM Article a WHERE author = id AND schedule < CURRENT_TIMESTAMP()") // limit = 15
private List<Article> pastArticles;
}
像这样,即使删除schedule <
子句的一部分,我也会保持pastArticles为空。
谢谢!
回答:
答案1:
@Size(max=10)private List<Comment> commentList;
答案2 :(仅是这样的例子)
public class A{ @Id
@GeneratedValue
private Integer id;
private String uuid;
...
}
其他班级
public class B{ @Id
@GeneratedValue
private Integer id;
private String uuidOfA;
@ManyToOne
@JoinColumnsOrFormulas({
@JoinColumnOrFormula(formula=@JoinFormula(value="(SELECT a.id FROM A a WHERE a.uuid = uuid)", referencedColumnName="id")),
@JoinColumnOrFormula(column = @JoinColumn("uuidOfA", referencedColumnName="uuid"))
})
private A a;
}
以上是 @JoinFormula和@OneToMany定义-较差的文档 的全部内容, 来源链接: utcz.com/qa/430436.html