Sharath Prakash (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMzAwNjhjYmJm...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16201?atlOrigin=eyJpIjoiMzAwNj...
) HHH-16201 (
https://hibernate.atlassian.net/browse/HHH-16201?atlOrigin=eyJpIjoiMzAwNj...
) getResultSet query with null parameter fails with native query in hibernate 6.1.7 (
https://hibernate.atlassian.net/browse/HHH-16201?atlOrigin=eyJpIjoiMzAwNj...
)
Issue Type: Bug Affects Versions: 6.1.7 Assignee: Unassigned Components: hibernate-core
Created: 20/Feb/2023 00:39 AM Environment: Hibernate Version: 6.1.7.Final
JVM: JDK 17.0.6
Operating System: Linux
Database: H2 & Postgres Labels: core native Priority: Major Reporter: Sharath Prakash
(
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
getResultSet query with null parameter fails with a native query in hibernate 6.1.7
Fails with Hibernate Native Query version: 6.1.7.Final.
GitHub Link for the test project with issue reproducible:-
GitHub Link (
https://github.com/SharathPrakash/Hibernate6DemoNullCheck )
Logs from the test cases
jakarta.persistence.PersistenceException: Converting
`org.hibernate.exception.SQLGrammarException` to JPA `PersistenceException` : could not
prepare statement
at
org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:165)
at org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:374)
at org.hibernate.query.Query.getResultList(Query.java:94)
at org.hibernate.bugs.JPAUnitTestCase.nativeQueryExample(JPAUnitTestCase.java:40)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at
com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: org.hibernate.exception.SQLGrammarException: could not prepare statement
at
org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:64)
at
org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:56)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
at
org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:186)
at
org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareStatement(StatementPreparerImpl.java:75)
at
org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.lambda$list$0(JdbcSelectExecutorStandardImpl.java:100)
at
org.hibernate.sql.results.jdbc.internal.DeferredResultSetAccess.executeQuery(DeferredResultSetAccess.java:171)
at
org.hibernate.sql.results.jdbc.internal.DeferredResultSetAccess.getResultSet(DeferredResultSetAccess.java:146)
at
org.hibernate.sql.results.jdbc.internal.AbstractResultSetAccess.getMetaData(AbstractResultSetAccess.java:33)
at
org.hibernate.sql.results.jdbc.internal.AbstractResultSetAccess.getColumnCount(AbstractResultSetAccess.java:49)
at
org.hibernate.query.results.ResultSetMappingImpl.resolve(ResultSetMappingImpl.java:187)
at
org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.resolveJdbcValuesSource(JdbcSelectExecutorStandardImpl.java:559)
at
org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.doExecuteQuery(JdbcSelectExecutorStandardImpl.java:350)
at
org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.executeQuery(JdbcSelectExecutorStandardImpl.java:166)
at
org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.list(JdbcSelectExecutorStandardImpl.java:91)
at org.hibernate.sql.exec.spi.JdbcSelectExecutor.list(JdbcSelectExecutor.java:31)
at
org.hibernate.query.sql.internal.NativeSelectQueryPlanImpl.performList(NativeSelectQueryPlanImpl.java:105)
at org.hibernate.query.sql.internal.NativeQueryImpl.doList(NativeQueryImpl.java:602)
at org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:363)
... 31 more
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "
select * from student a where (? is null or a.first_name in [*]?)\000a"; expected
"("; SQL statement:
select * from student a where (? is null or a.first_name in ?)
[42001-214]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:502)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
at org.h2.message.DbException.getSyntaxError(DbException.java:261)
at org.h2.command.Parser.getSyntaxError(Parser.java:900)
at org.h2.command.Parser.read(Parser.java:5675)
at org.h2.command.Parser.readInPredicate(Parser.java:3261)
at org.h2.command.Parser.readConditionRightHandSide(Parser.java:3167)
at org.h2.command.Parser.readCondition(Parser.java:3144)
at org.h2.command.Parser.readExpressionPart2(Parser.java:3060)
at org.h2.command.Parser.readExpression(Parser.java:3053)
at org.h2.command.Parser.readTermWithoutIdentifier(Parser.java:4990)
at org.h2.command.Parser.readTerm(Parser.java:4901)
at org.h2.command.Parser.readFactor(Parser.java:3398)
at org.h2.command.Parser.readSum(Parser.java:3385)
at org.h2.command.Parser.readConcat(Parser.java:3350)
at org.h2.command.Parser.readCondition(Parser.java:3132)
at org.h2.command.Parser.readExpressionWithGlobalConditions(Parser.java:3043)
at org.h2.command.Parser.parseSelect(Parser.java:2881)
at org.h2.command.Parser.parseQueryPrimary(Parser.java:2762)
at org.h2.command.Parser.parseQueryTerm(Parser.java:2633)
at org.h2.command.Parser.parseQueryExpressionBody(Parser.java:2612)
at org.h2.command.Parser.parseQueryExpressionBodyAndEndOfQuery(Parser.java:2605)
at org.h2.command.Parser.parseQueryExpression(Parser.java:2598)
at org.h2.command.Parser.parseQuery(Parser.java:2567)
at org.h2.command.Parser.parsePrepared(Parser.java:724)
(
https://hibernate.atlassian.net/browse/HHH-16201#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16201#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100217- sha1:d96fecc )