我有一个班级说: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.
这篇关于使用引用类休眠@OrderBy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
有没有办法使用 SQL 获取有关服务器的信息Is there a way to get information about a server using SQL(有没有办法使用 SQL 获取有关服务器的信息)
如何在 Oracle 中通过 XPath 获取第一个元素How to get first element by XPath in Oracle(如何在 Oracle 中通过 XPath 获取第一个元素)
Oracle XMLTable-从父节点获取列Oracle XMLTable- fetching column from parent node(Oracle XMLTable-从父节点获取列)
如何从 XMLType 节点中提取元素路径?How to extract element-path from XMLType Node?(如何从 XMLType 节点中提取元素路径?)
使用取自序列的值将属性添加到 xmltypeAdd attribute to xmltype with value taken from sequence(使用取自序列的值将属性添加到 xmltype)
即使表达式值为空,如何强制执行 xmlforest creatHow to enforce xmlforest creat elements even if expression value is null?(即使表达式值为空,如何强制执行 xmlforest creat 元素?)