Hibernate中的查询范围

时间:2020-09-12 18:56:53

标签: hibernate

在Hibernate中是否有与ActiveRecord范围类似的东西?可以在哪里链接子句?

class Shirt < ActiveRecord::Base
  scope :red, -> { where(color: 'red') }
  scope :dry_clean_only, -> { joins(:washing_instructions).where('washing_instructions.dry_clean_only = ?', true) }
end

# List all red, dry-clean-only shirts
Shirt.dry_clean_only.red

# List all of Elton's red, dry-clean-only shirts
elton.shirts.red.dry_clean_only

我见过@Where@Filter注释,但它们似乎分别适用于整个类或整个会话。

0 个答案:

没有答案
相关问题