-->
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.  [ 8 posts ] 
Author Message
 Post subject: is there a way to create criteria from the Named query?
PostPosted: Mon May 21, 2007 8:33 am 
Newbie

Joined: Tue May 15, 2007 5:02 pm
Posts: 12
is there a way to create friteria from named query in Hibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 21, 2007 8:42 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
no

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 21, 2007 8:49 am 
Newbie

Joined: Tue May 15, 2007 5:02 pm
Posts: 12
thanks for the reply...

I just want to put a global filter on all the named queries being executed.. is there a efficient way to do that in hibernate?

again your help is appreciated..

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 21, 2007 8:58 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
well. you have the Query object after the getNamedQuery call. So, you can modify it right there.

or have your own method called automatically whenever getNamedQuery is called (AoP, or some other way)

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 21, 2007 9:03 am 
Newbie

Joined: Tue May 15, 2007 5:02 pm
Posts: 12
I cannot modify the query object to put more restrictions right..? like I want to add a where clause, which is more generic and is applicable to almost all the queries in the application...

thanks in advance..


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 21, 2007 9:20 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
you could try something like:

Code:
Query q = session.getNamedQuery("asf");

Query q1 = new Query(q.getQueryString()+"where ...");


_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 21, 2007 9:30 am 
Newbie

Joined: Tue May 15, 2007 5:02 pm
Posts: 12
yes I tried something like this... which works for the simple queries but not sure about the complex queries. I am looking for something that keep a filter at the session level that is applied for each query executed for that session.

but still this discussion was helpful.. Thanks again... and let me know if have any further ideas...


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 21, 2007 9:57 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
check the Interceptor API. EmptyInterceptor is one of the interfaces you might want to look at. I think you can implement filters in there.

I just don't do much with interceptors so I'm not totally sure

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


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

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.