Showing posts with label bug. Show all posts
Showing posts with label bug. Show all posts

Thursday, April 11, 2013

Hibernate NullPointerException on getNamedParameterExpectedType

I received this very cryptic message from a Hibernate query today:
java.lang.NullPointerException at org.hibernate.hql.internal.ast.ParameterTranslationsImpl.getNamedParameterExpectedType(ParameterTranslationsImpl.java:87) at org.hibernate.engine.query.spi.HQLQueryPlan.buildParameterMetadata(HQLQueryPlan.java:319) at org.hibernate.engine.query.spi.HQLQueryPlan.(HQLQueryPlan.java:124) at org.hibernate.engine.query.spi.HQLQueryPlan.(HQLQueryPlan.java:80) at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168) at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:219) at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:197) ...
A quick google search found this bug which basically says you have too many parenthesis.

So, watch your closing parenthesis because Hibernate doesn't know how to give helpful error messages.

Monday, July 2, 2012

Hibernate: Map Separate Date and Time Columns to a Date

I ran into a problem where I was trying to get Hibernate to map seperate date and time columns from an SQL Server to one Date object

In my query editor CAST(from_date AS DATETIME) + CAST(from_time AS TIME) worked just fine so I plugged it into a @Formula, but it turns out Hibernate really wanted to put the table alias in from of the keyword DATETIME(HHH-2967)

After some cursing at Hibernate I finally came up with a formula that works

Simply put, I'm just converting the date to a string and then concatenating the time as a string. Fairly simple, but a pain.