-->
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: NullPointerExceptions with my query
PostPosted: Wed Jul 08, 2009 9:33 am 
Newbie

Joined: Wed Jul 08, 2009 9:22 am
Posts: 1
<disclaimer>I am a JPA/Hib noob.</disclaimer>

I've got a table with some numeric columns, but I need to do some string comparisons using the LIKE phrase. So I've got a query like:
Code:
SELECT re FROM ResEntity re WHERE (CAST(re.x AS string) LIKE :match) OR (CAST(re.y AS string) LIKE :match)
While Hibernate will accept this query, calling q.set("match", "123%") only sets the first occurrence of "match", so I don't find all the rows. [BUG 1]

If I change the query to use :match1 and :match2, I get a NullPointerException on the createQuery() call. [BUG 2]

If I change the query to use ?1 and ?2, I get a NPE on the createQuery() call. [BUG 3]

Do I have 3 bugs, or am I just coming at this the wrong way.

I know there are other ways to get this done, but would like to understand why this doesn't work.

Thanks for any help!


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.