Hello,

Is it possible in OJB to do these two things?

1. Create a Query representing the intersection of two other
Queries (intersection to be executed in the database)

2. Use Criteria.addEqualToField() within a subquery where the named
field actually comes from an object in a parent or grandparent query.

Thanks,
Scott Howlett


PS - To explain a bit more, here's a simplified version of what
I'm trying to do.

Represent access privileges between users and documents:

- Users can be in groups, documents can also be in groups
- Entitlement is specified either directly (user_id <-> document_id)
  or indirectly (via user or group id).
- id values are globally unique.

tables are like this (just showing the primary key columns):

user { id }
user_group { id }
user_group_membership { user_id, user_group_id }

doc { id }
doc_group { id }
doc_group_membership { doc_id, doc_group_id }

entitlement { user_or_user_group_id, doc_or_doc_group_id }

Given a particular user with id <USER_ID>, accessible documents are
those with a non-null intersection of (user / user group entitlements)
and (doc / doc group entitlements) (pseudo-SQL):

select * from doc where

(select count (*) from (        
    (select * from entitlement where
        (user_or_user_group_id = <USER_ID>) or
        (user_or_user_group_id in
            (select user_group_id from user_group_membership where
             user_id = <USER_ID>)))

    intersect

    (select * from entitlement where
        (doc_or_doc_group_id = id) or
        (doc_or_doc_group_id in
           (select doc_group_id from doc_group_membership where
            doc_id = id)))
)) > 0

My question #1 is because of the 'intersect' statement.

My question #2 is because in the second sub-sub-query, I'm
twice referring to the document field 'id' which comes
from the top-level query 'select * from doc'.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to