0

What does the following Hibernate error mean? We have existing code that used to work before a Spring/Hibernate upgrade.

java.lang.NullPointerException: null
    at org.hibernate.param.PositionalParameterSpecification.bind(PositionalParameterSpecification.java:55) ~[hibernate-core-5.6.8.Final.jar:5.6.8.Final]
    at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:682) ~[hibernate-core-5.6.8.Final.jar:5.6.8.Final]
    at org.hibernate.loader.Loader.bindPreparedStatement(Loader.java:2150) ~[hibernate-core-5.6.8.Final.jar:5.6.8.Final]
    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2127) ~[hibernate-core-5.6.8.Final.jar:5.6.8.Final]
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2059) ~[hibernate-core-5.6.8.Final.jar:5.6.8.Final]
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2037) ~[hibernate-core-5.6.8.Final.jar:5.6.8.Final]

On this DAO method:

@Query("select s from TraineeSearch s where s.trainDirectorNedId=?1 and s.nedId in?2 and s.plan IS NOT NULL and s.currentPlan ='Y'")
List<TraineeSearch> getTerminatedTrainees(String nedId,List<String> nedIds);

1 Answer 1

1

Support for ? i.e query parameter has been removed in Hibernate 5.3.

You need to use named parameters in the query.

@Query("select s from TraineeSearch s where s.trainDirectorNedId=:nedIdParameter and s.nedId in:nedIdsParameter and s.plan IS NOT NULL and s.currentPlan ='Y'")
List<TraineeSearch> getTerminatedTrainees(String nedId,List<String> nedIds);

and then set following parameters

query.setParameter("nedIdParameter ", nedId);
query.setParameter("nedIdsParameter ", nedIds);

You can refer this migration guide.

http://wiki.openbravo.com/wiki/Hibernate_5.3_Migration_Guide#Positional_Parameters_are_not_Supported

Sign up to request clarification or add additional context in comments.

1 Comment

Maybe PositionalParameterSpecification shows that this hibernate version used implements the positional parameters, I would rather think that the problem is here : in?2. I would say you need at least a space in between and maybe brackets around the ?2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.