-->
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: removing a where constraint out of a named query
PostPosted: Wed Jul 20, 2005 10:01 am 
Newbie

Joined: Wed Jul 20, 2005 9:40 am
Posts: 11
Location: Augsburg
Hi!
I want to use a named query to get the results for the user's search page. However, i only need to insert 'where constraints' for the fields that have been filled in with values.
So here are my questions:
- does the 'namedQuery.setParameter("fieldName", null)' ignore this constraint for any relational database?
- is it possible to remove a where constraint (e.g. 'where name = :name') out of the query object before executing the query?

Any comments are greatly appreciated!
Thanks in advance,
Christian


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 10:53 am 
Regular
Regular

Joined: Thu Jul 08, 2004 1:21 pm
Posts: 68
Location: Recife - Pernambuco - Brazil
No, you could not do it using named queries. Use Criteria API instead.

valeuz...

_________________
Marcos Silva Pereira
http://blastemica.blogspot.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 7:09 pm 
Newbie

Joined: Wed Jul 20, 2005 9:40 am
Posts: 11
Location: Augsburg
thanks a lot,
regards!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 8:52 pm 
Beginner
Beginner

Joined: Thu May 26, 2005 12:31 pm
Posts: 25
can I use queries involving joining of multiple tables if I use Criteria API?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 9:48 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
yes. read the docs.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 11:19 pm 
Beginner
Beginner

Joined: Thu May 26, 2005 12:31 pm
Posts: 25
thanks for the reply. I'm just reading "hibernate in action".

i've a complex oracle sql query joins multiple tables..
need to use oracle hints for performance boosting. So thought of using native sqls.
But want to externalise using named queries.

the query is pretty dynamic also. need to change the "where" conditions dynamically.

I think I can't acheive this in hibernate. (am I right?)

Is there any java api where I can express my sql queries in xml?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 22, 2005 2:09 am 
Newbie

Joined: Wed Jul 20, 2005 11:50 pm
Posts: 4
Location: Allentown, PA
Maybe just put the queries (or where clauses if these are all that vary) in xml CDATA sections? IIRC the OReilly developer notebook "Harnessing Hibernate" has examples like this.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 22, 2005 7:50 am 
Beginner
Beginner

Joined: Thu May 26, 2005 12:31 pm
Posts: 25
Could you pls put an exmple here, as i dont have that book "Harnessing Hibernate"?

Thanks a lot.


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.