RSS

Hibernate Errors

I got NullPOinter Exception and I nearly wasted four long hours to detect the actual Problem. The error log shows the following:

 

Exception in thread “main” java.lang.NullPointerException
at org.hibernate.hql.ast.ParameterTranslationsImpl.getNamedParameterExpectedType(ParameterTranslationsImpl.java:63)
at org.hibernate.engine.query.HQLQueryPlan.buildParameterMetadata(HQLQueryPlan.java:296)
at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:97)
at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:400)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:351)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:121 
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:691)

 

After a lot og Googling I found that this error was happening due to the space given after the colon in the hibernnate query. 

Like

SELECT LOCATION FROM LOCATION WHERE LOCATION.ID = :  ID

here to rempve the error we have to remove the space given between : and ID. So the query will become 

SELECT LOCATION FROM LOCATION WHERE LOCATION.ID = : ID

The error message should throw relevant information but it is not so. Hope this will help you.

 

2 responses to “Hibernate Errors

  1. Shyano

    May 4, 2009 at 9:16 am

    Thanks …. It saved my time…

     
  2. Prathamesh

    April 23, 2011 at 6:28 am

    Even for http://opensource.atlassian.com/projects/hibernate/browse/HHH-3123

    Further, sub-queries within parenthesis throws the same exception even when pairs are matched.

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: