-->
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: CastFunction throws NullPointerException
PostPosted: Mon Jun 05, 2006 1:24 pm 
Newbie

Joined: Mon Jun 05, 2006 1:10 pm
Posts: 1
Running a query like this:

Code:
SELECT p.lastname FROM Person p
WHERE SOUNDEX(p.lastname) = SOUNDEX(CAST(? AS STRING))


causes a NullPointerException in the render method of org.hibernate.dialect.function.CastFunction. Reason for this exception is TypeFactory.heuristicType returning null for a type called "STRING":

Code:
   public String render(List args, SessionFactoryImplementor factory) throws QueryException {
      if ( args.size()!=2 ) {
         throw new QueryException("cast() requires two arguments");
      }
      String type = (String) args.get(1);
      int[] sqlTypeCodes = TypeFactory.heuristicType(type).sqlTypes(factory);
      ...


Replacing "STRING" with "string" in the query cures the problem. As HQL and SQL are case-insensitive most of the time I wonder if it would make sense also to make this function case-insenstive regarding the type parameter. Well, but at least a more meaning-full exception should be thrown, I guess.

Hibernate version:
3.1.3

Mapping documents:
Doesn't matter here I guess.

Code between sessionFactory.openSession() and session.close():
Doesn't matter here I guess.

Full stack trace of any exception that occurs:
Doesn't matter here I guess.

Name and version of the database you are using:
IBM DB/2

The generated SQL (show_sql=true):
None

Debug level Hibernate log excerpt:
Doesn't matter here I guess.


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.