-->
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.  [ 4 posts ] 
Author Message
 Post subject: using null with setParameter??
PostPosted: Wed Feb 11, 2004 7:50 pm 
Beginner
Beginner

Joined: Sun Oct 05, 2003 9:02 pm
Posts: 27
Location: New York, NY
Hi-

Having a query with multiple parameters, I sometimes need to execute it with one of the parameters having a value of null. Other times, the parameter does have a value set.

Is there any way to accomplish this with a single query using setParameter?

It seems it could be accomplished with two different queries -- one using "is null" and the other using the setParameter approach, but that is a bit too messy.

Any help is appreciated.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 10:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is not supported by JDBC, hence not by Hibernate. It is a good case for using the Criteria API.


Top
 Profile  
 
 Post subject: grrr...
PostPosted: Wed Feb 11, 2004 10:21 pm 
Beginner
Beginner

Joined: Sun Oct 05, 2003 9:02 pm
Posts: 27
Location: New York, NY
somebody should change the jdbc spec....

i'll give the criteria api a shot.

thnx


Top
 Profile  
 
 Post subject: follow up question...
PostPosted: Wed Feb 11, 2004 10:26 pm 
Beginner
Beginner

Joined: Sun Oct 05, 2003 9:02 pm
Posts: 27
Location: New York, NY
one quick Q...

why does the setParameter(parameter, object, hibernateType) method accept null? it accepts it, but obviously doesn't perform an "is null".

just curious.

thnx


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