使用引用类休眠@OrderBy
我有一个班级说:ClassA",其中包含ClassB"的集合
I have a class say: "ClassA" which has a collection of "ClassB"
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "COLUMN_NAME")
private List<ClassB> lotsOfClasses;
ClassB"具有使用普通旧映射注释的映射类ClassC":
"ClassB" has a mapped class "ClassC" using plain old mapping annotations:
public class ClassB {
...
@ManyToOne
@JoinColumn(name="AD_POINT_ID")
private ClassC classC;
...
}
如何给ClassA的集合添加@OrderBy注解到ClassB,让集合按照ClassC的name"属性排序
How do I add an @OrderBy annotation to ClassA's collection to ClassB, so that the collection is ordered by the "name" property of ClassC
像这样:
@OrderBy(clause="classC.name asc")
我得到的只是 Oracle 异常,说 classC 是未知的.
All I get are Oracle exceptions saying that classC is unknown.
这里的任何帮助都会很棒,因为它现在真的让我很烦恼.
Any help here would be awesome, as its really bugging me at the moment.
P.S.我还应该提到在集合上使用 OrderBy 注释,如下所示:@OrderBy(clause="classC asc")(即没有 classC 上的 .name)我得到一个有效的 SQL 语句,它使用 classC 的 ID 列(主键)进行排序.
干杯,标记
推荐答案
很遗憾,您无法做您想做的事.我在此处回答了类似的问题.
It's unfortunately impossible to do what you want. I've answered a similar question here.
@OrderBy
仅支持集合元素的 direct 属性.
@OrderBy
only supports direct properties of the collection elements.
相关文章