gpt4 book ai didi

java - 使用 Hibernate 条件查询无顺序

转载 作者:行者123 更新时间:2023-12-01 15:32:31 25 4
gpt4 key购买 nike

我正在尝试按日期时间获取实体列表及其集合顺序,但我不明白。这是我的查询:

trades = session.createCriteria(Trade.class)
.createAlias("operations", "operations", CriteriaSpecification.INNER_JOIN)
.add(Restrictions.between("operations.datetime", start, end))
.addOrder(Order.asc("operations.datetime"))
.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY)
.list();

根据 hibernate,这些是查询:

select 
this_.MUREX_ID as MUREX1_0_1_,
this_.PORTFOLIO as PORTFOLIO0_1_,
this_.TYPE as TYPE0_1_,
operations1_.ID as ID1_0_,
operations1_.COMENT as COMENT1_0_,
operations1_.DATETIME as DATETIME1_0_,
operations1_.GBO_ID as GBO4_1_0_,
operations1_.OPERATION as OPERATION1_0_,
operations1_.OPERATION_ID as OPERATION6_1_0_,
operations1_.OPICS_ID as OPICS7_1_0_,
operations1_.STATUS_GBO as STATUS8_1_0_,
operations1_.STATUS_MUREX as STATUS9_1_0_,
operations1_.MUREX_ID as MUREX10_1_0_
from
PGT_NY.T_PGT_NY_BLOTTER_TRADES_S this_,
PGT_NY.T_PGT_NY_BLOTTER_OPERATIONS_S operations1_
where
this_.MUREX_ID=operations1_.MUREX_ID and
operations1_.DATETIME between ? and ?
order by operations1_.DATETIME asc

还有:

select 
operations0_.MUREX_ID as MUREX10_1_,
operations0_.ID as ID1_,
operations0_.ID as ID1_0_,
operations0_.COMENT as COMENT1_0_,
operations0_.DATETIME as DATETIME1_0_,
operations0_.GBO_ID as GBO4_1_0_,
operations0_.OPERATION as OPERATION1_0_,
operations0_.OPERATION_ID as OPERATION6_1_0_,
operations0_.OPICS_ID as OPICS7_1_0_,
operations0_.STATUS_GBO as STATUS8_1_0_,
operations0_.STATUS_MUREX as STATUS9_1_0_,
operations0_.MUREX_ID as MUREX10_1_0_
from
PGT_NY.T_PGT_NY_BLOTTER_OPERATIONS_S operations0_
where
operations0_.MUREX_ID in (
select
this_.MUREX_ID
from
PGT_NY.T_PGT_NY_BLOTTER_TRADES_S this_,
PGT_NY.T_PGT_NY_BLOTTER_OPERATIONS_S operations1_
where
this_.MUREX_ID=operations1_.MUREX_ID and
operations1_.DATETIME between ? and ?
)

任何帮助都会非常有用。

提前致谢!

最佳答案

我觉得不错。您应该得到一个按其操作的日期时间排序的交易列表,这意味着具有较小日期时间的操作的交易排在第一位,然后是具有第二小的操作的交易。

贸易对象的集合按照映射中的规定进行排序。你必须将它们单独排序。 Hibernate 不会在加载时执行此操作,因为它会破坏列表、索引集合等的更改跟踪。

关于java - 使用 Hibernate 条件查询无顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9402299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com