-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Query the index of a map using criteria
PostPosted: Fri Oct 30, 2009 8:56 am 
Newbie

Joined: Tue Jan 06, 2009 5:08 am
Posts: 10
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.