-->
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: How can I use a stored procedure w/ a query by example call?
PostPosted: Mon Dec 17, 2012 12:07 pm 
Newbie

Joined: Mon Dec 17, 2012 11:21 am
Posts: 1
My application has to retrieve a list of users and then has to determine if the person making the search is "allowed" to see each of the returned users.

Currently, we achieve this by constructing an Example user, retrieving the users that match that Example, and then running a stored procedure on the returned users to check if the searcher can "see" them.

So when a user searches for other users, it goes like this:
Step 1: Create example user
Step 2: Get users in DB that match example
Step 3: Loop through results of Step 2, run the "can this searcher see this returned user" stored procedure for EACH returned user
Step 4: Only return the users that Step 3 authorized

What I'd like to do is get rid of the "post-processing" situation we have right now because it is awful for performance. Due to various business edicts, the only "acceptable" way to do this would be to add the stored procedure to the Hibernate Example/Criteria somehow. That is, combine Step 1 and Step 3, without making Step 1 a stored procedure and still use the stored procedure in Step 3. The stored procedure must be used as is, as per business rules, and can't be ripped out into equivalent HQL/SQL.

Is that possible? Can anyone give me any insight on this?

*Edit* I should clarify: The stored procedure is pretty much just a lookup on a table that maps user IDs to user IDs. It returns 0 if the searching user can't see the returned user and 1 (or greater) if the searching user can see the returned user. The stored procedure also does a check on another table to see if the searching user is a superuser and can automatically see everyone and, if so, will automatically return 1.


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.