【问题标题】:How to get a greater than record in Hibernate - Criteria Queries?如何在 Hibernate - Criteria Queries 中获得大于记录?
【发布时间】:2019-01-21 15:50:42
【问题描述】:

金额值为 Big Decimal 类型,逻辑应为 _customerPayeeTransaction.getAmount() > 10 000.00

如何更改以下条件以匹配上述逻辑?

Criterion amount = Restrictions.gt("cpt.amount", _customerPayeeTransaction.getAmount());

请帮帮我。

【问题讨论】:

  • 到底是什么问题?你的金额是BigDecimal的问题吗?
  • 我想实现上面提到的那个逻辑。
  • _customerPayeeTransaction.getAmount() > 10 000.00
  • 好吧,在我看来你已经完成了
  • 如果我写这个标准 amount = Restrictions.gt("cpt.amount", _customerPayeeTransaction.getAmount());它会过滤大于 10 000.00 的金额值吗?

标签: java spring hibernate criteria hibernate-criteria


【解决方案1】:
If u want to add filter amount lower than 10 000 : 

Criterion amount = Restrictions.lt("cpt.amount", new BigDecimal("10000.00"));

【讨论】:

  • .lt 或 .gt 这取决于你想要什么 :)
猜你喜欢
  • 2010-10-07
  • 2011-04-23
  • 2021-01-17
  • 1970-01-01
  • 2012-08-10
  • 1970-01-01
  • 2017-03-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多