Steve, you are true. The jdbc driver was escaping respective information and I dont need to do specifically.
I have a question regarding the numbers used to bind positional parameters. Will it start from 0 or 1. In your above query you have been using
setString( 1, "Mac'Donalds" );
When I use '1' instead of '0', was getting the following exception.
Code:
java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!
at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterDescriptor(ParameterMetadata.java:55)
at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterExpectedType(ParameterMetadata.java:61)
at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:382)
at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:362)
But when I use setString( 0, "Mac'Donalds" ) everything is working fine. I am confused especially with the exception message is conflicting to the number I used to bind parameters.
-----
an update - I was using setParameter( 1, "Mac'Donalds" );
and when I use setString( 1, "Mac'Donalds" ) the exception is as follows
Code:
11:10:19,151 DEBUG ErrorCounter:68 - throwQueryException() : no errors
java.lang.IllegalArgumentException: Positional parameter does not exist: 1 in query: from HibernatePojo myObject where myObject.name like ?
at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:328)
at org.hibernate.impl.AbstractQueryImpl.setString(AbstractQueryImpl.java:434)