-->
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.  [ 5 posts ] 
Author Message
 Post subject: How do I manuplate the named query at run time?
PostPosted: Tue May 15, 2007 5:30 pm 
Newbie

Joined: Tue May 15, 2007 5:02 pm
Posts: 12
I am using EJB 3.0 entity beans and I have a specific requirement. I need to modify the named query at the run time like add some extra search criteria just before the actual execution. This needs to be done at the framework lavel so that developer do not care about it.

Can any body help?

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 10:57 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Use criteria.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 6:41 am 
Newbie

Joined: Tue May 15, 2007 5:02 pm
Posts: 12
Can you explain exactly how to use it?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 7:41 am 
Newbie

Joined: Wed May 16, 2007 6:16 am
Posts: 3
rahulbhirud wrote:
Can you explain exactly how to use it?


Code:
List cats = session.createCriteria(Cat.class)
     .add( Restrictions.like("name", "Iz%") )
     .add( Restrictions.gt( "weight", new Float(minWeight) ) )
     .addOrder( Order.asc("age") )
     .list();


http://www.hibernate.org/hib_docs/v3/api/org/hibernate/Criteria.html


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 17, 2007 9:18 am 
Newbie

Joined: Tue May 15, 2007 5:02 pm
Posts: 12
hey thanks for the reply... but sorry this is to create the new query itself. I want to modify the existing named query to add more conditions. The existing query can be complex query.

any suggestions would be appreciated...

Thanks in advance...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.