0

HQLに問題があります。

かなり複雑なクエリを実行したいのですが、次の Domain-Object (簡略化) があります。

class SomeObject {
    Set<SomeOtherObject> otherObjects
}

指定した他のオブジェクトのリストを 1 つ以上含むすべてのオブジェクトを取得したいと考えています。さらに、オブジェクトに含まれてはならない otherObjects のブラックリストも必要です。

ここまでできました。1 つのブラックリスト項目と「許可された」otherObjects のリストのみを指定できます。

select o from Object as o 
join o.otherObjects as otherObject 
where 
    otherObject in :allowedotherobjects 
    and :excludedotherobject not in elements(o.otherObjects)

基本的に私はこのようなものが欲しいです(これは不可能です):

select o from Object as o 
join o.otherObjects as otherObject 
where 
    otherObject in :allowedotherobjects 
    and elements(:excludedotherobjects) not in elements(o.otherObjects)

ところで、これは私が取り組んでいる grails プロジェクトですが、この問題を HQL で解決したいと考えています。

何か案は?

4

1 に答える 1