I have been trying to write a hibernate query and have been able to generate the hibernate query through the server, but the parameters in the parameterized query are not getting binded correctly i.e. if 23 is to be binded to parameter 1, but it's getting binded to paramter 3.
Any idea why this would be happening? What should be the points of errors that I should check to get to the root cause of this issue?
EDIT (Why the query is not here?)
The hibernate query is a complex one and it is not possible for me to publish it here. That's why my question is a general one. I just wanted to know, if someone else has also faced this issue, in which hibernate throws no errors and the query is generated successfully, but it's binding incorrect data to incorrect parameter.
I will try to give a rough idea through an example --> e.g you write:
criteria.createAlias("D.A", "a", CriteriaSpecification.LEFT_JOIN, Restrictions.eq("a.delIndc", false));
criteria.createAlias("A.B", "ab", CriteriaSpecification.LEFT_JOIN,
Restrictions.sqlRestriction("sqlQuery"));
criteria.createAlias("ab.c", "abc", CriteriaSpecification.LEFT_JOIN, Restrictions.eq("c.dataEntry", "Star Wars"));
criteria.createAlias("abc.f", "f", CriteriaSpecification.LEFT_JOIN, Restrictions.eq("f.dataExit", "Star Trek"));
The query is getting generated successfully in the server (no error thrown), but while doing the parameter binding:
2017-12-09 12:09:21,396 TRACE [org.hibernate.jdbc.AbstractBatcher] (pool-14-thread-2) preparing statement
2017-12-09 12:09:21,396 TRACE [org.hibernate.type.BooleanType] (pool-14-thread-2) binding 'false' to parameter: 1
2017-12-09 12:09:21,396 TRACE [org.hibernate.type.BooleanType] (pool-14-thread-2) binding 'Star Trek' to parameter: 2
2017-12-09 12:09:21,396 TRACE [org.hibernate.type.BooleanType] (pool-14-thread-2) binding 'Star Wars' to parameter: 3
So, instead of binding 'Star Wars' to parameter 2, it's getting bind incorrectly to parameter 3.
So, in a nutshell, I want to know, why this might be happening? What are the checks I need to do to get to the root cause of this? And also if you faced this issue, how you found the issue and how you resolved it?
Hope this clarifies my query further. Please help and let me know, if you need any more info in this regard.