NullPointerException in AbstractSqlAstTranslator?

Hi all,

In Hibernate 6.5.2, I am executing a quite basic HQL query like

var q=createQuery("select z from Entity z where nummer=:nummer and datum=:datum", Entity.class);
q.setReadOnly(true);
q.setParameter("nummer", nummer);
q.setParameter("datum", datum, MyOwnDateJavaType.TYPE);

As you can see, the only special is an own wrapper around DATE type.

When I execute that query, I get an NPE in AbstractSqlAstTranslator line 8251:
SqlTupleContainer.getSqlTuple( comparisonPredicate.getRightHandExpression() ).getExpressions().get( 0 )

because getSqlTuple returns null. The actual call is SqlParameterInterpretation.getSqlTuple, which looks for getResolvedExpression’s type to be SqlTuple, but it actually is JdbcParameterImpl.

I got curious because of this left/right hand side thing and just swapped the expression around:
var q=createQuery("select z from Entity z where nummer=:nummer and :datum=datum", Entity.class);

… and it works fine.

Is this a bug, or am I doing something wrong? Isn’t a parameter allowed as right hand side?

Marcus.

Yeah, that’s a bug. Please try to create a reproducer with our test case template and if you are able to reproduce the issue, create a bug ticket in our issue tracker and attach that reproducer.

Hi beikov,

creating the minimal reproducer showed me that there’s an error in the legacy HQL. There is an important detail I oversaw when debugging: the attribute called “datum” in the above example is an @Embeddable, therefore the correct HQL syntax would be “datum.value=:datum”.

It’s a mix of creating an own wrapper around LocalDate, and wrapping this into an @Embeddable (sorry for this architecture - stripping it down to the minimal reproducer makes it look really silly), and referring it with a wrong syntax.

So, this isn’t an actual Hibernate bug, but if you’d like the error message to be improved, I’d be happy to file an issue. The minimal reproducer is already working.

Sure, please create a Jira issue for this.

Done: Jira

1 Like