Hi there,
I am desperately trying to create a criteria to access an object that contains a map. The problem here is, that the map contains a user restriction like in the following definition:
Code:
<class name="PersistentObject">
<id name="id" column="ID" length="32">
<generator class="uuid" />
</id>
...
<map name="userAccess" table="ACCESS_RIGHTS" lazy="false">
<key column="OBJECT_ID" />
<map-key column="USER_ID" type="string" length="32" />
<element column="USER_RIGHT" type="int" />
</map>
</class>
The userAccess field stores the access right for every user (no user can have more than one access right).
In HQL I would do something like this:
Code:
select distinct c from PersistentObject c inner join c.userAccess ua where index(ua) in ('id1', 'id2', 'id15')
where id1 would be the user's id and id2 and id15 would be group ids.
Now I have reached the point, that using HQL is not easily handled anymore, since my users of the application can add more restrictions to the query (which makes it very dynamic, especially when using nested restrictions). Using Criteria, it will be much easier to create a query from the filter definitions of the users.
Greetings,
Torti