org.hibernate.exception.SQLGrammarException: could not extract ResultSet

Hibernate JIRA | Tobias Brueggemann | 8 months ago
  1. 0

    For example, enabling {{org.hibernate.test.subselect.CompositeIdTypeBindingTest}} for SQL-Server by removing the corresponding annotation {{@SkipForDialect}} and running the matrix-test on an SQL-Server would produce the following exception. {noformat} org.hibernate.exception.SQLGrammarException: could not extract ResultSet at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:106) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:79) at org.hibernate.loader.Loader.getResultSet(Loader.java:2115) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1898) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1874) at org.hibernate.loader.Loader.doQuery(Loader.java:919) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:306) at org.hibernate.loader.Loader.loadCollectionSubselect(Loader.java:2385) at org.hibernate.loader.collection.SubselectCollectionLoader.initialize(SubselectCollectionLoader.java:63) at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:682) at org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:75) at org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:2004) at org.hibernate.collection.internal.AbstractPersistentCollection$4.doWork(AbstractPersistentCollection.java:562) at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:246) at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:558) at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:131) at org.hibernate.collection.internal.AbstractPersistentCollection$1.doWork(AbstractPersistentCollection.java:160) at org.hibernate.collection.internal.AbstractPersistentCollection$1.doWork(AbstractPersistentCollection.java:145) at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:246) at org.hibernate.collection.internal.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:144) at org.hibernate.collection.internal.PersistentBag.size(PersistentBag.java:261) at org.hibernate.test.subselect.CompositeIdTypeBindingTest.testCompositeTypeBinding(CompositeIdTypeBindingTest.java:78) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:45) 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.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:74) Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: An expression of non-boolean type specified in a context where a condition is expected, near ','. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:217) at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1635) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:426) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:372) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:6276) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1793) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:184) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:159) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:284) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70) ... 33 more {noformat} This is due to execution of this SQL-statement which is invalid for SQL-Server: {noformat} select employees0_.EmployeeGroup_departmentName as Employee1_2_1_, employees0_.EmployeeGroup_groupName as Employee2_2_1_, employees0_.employees_id as employee3_2_1_, employee1_.id as id1_0_0_, employee1_.name as name2_0_0_ from EmployeeGroup_Employee employees0_ inner join Employee employee1_ on employees0_.employees_id=employee1_.id where ( employees0_.EmployeeGroup_departmentName, employees0_.EmployeeGroup_groupName ) in ( select employeegr0_.departmentName, employeegr0_.groupName from EmployeeGroup employeegr0_ where employeegr0_.departmentName=? and employeegr0_.groupName=? or employeegr0_.departmentName=? and employeegr0_.groupName=? or employeegr0_.departmentName=? and employeegr0_.groupName=? ) {noformat}

    Hibernate JIRA | 8 months ago | Tobias Brueggemann
    org.hibernate.exception.SQLGrammarException: could not extract ResultSet
  2. 0

    For example, enabling {{org.hibernate.test.subselect.CompositeIdTypeBindingTest}} for SQL-Server by removing the corresponding annotation {{@SkipForDialect}} and running the matrix-test on an SQL-Server would produce the following exception. {noformat} org.hibernate.exception.SQLGrammarException: could not extract ResultSet at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:106) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:79) at org.hibernate.loader.Loader.getResultSet(Loader.java:2115) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1898) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1874) at org.hibernate.loader.Loader.doQuery(Loader.java:919) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:306) at org.hibernate.loader.Loader.loadCollectionSubselect(Loader.java:2385) at org.hibernate.loader.collection.SubselectCollectionLoader.initialize(SubselectCollectionLoader.java:63) at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:682) at org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:75) at org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:2004) at org.hibernate.collection.internal.AbstractPersistentCollection$4.doWork(AbstractPersistentCollection.java:562) at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:246) at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:558) at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:131) at org.hibernate.collection.internal.AbstractPersistentCollection$1.doWork(AbstractPersistentCollection.java:160) at org.hibernate.collection.internal.AbstractPersistentCollection$1.doWork(AbstractPersistentCollection.java:145) at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:246) at org.hibernate.collection.internal.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:144) at org.hibernate.collection.internal.PersistentBag.size(PersistentBag.java:261) at org.hibernate.test.subselect.CompositeIdTypeBindingTest.testCompositeTypeBinding(CompositeIdTypeBindingTest.java:78) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:45) 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.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:74) Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: An expression of non-boolean type specified in a context where a condition is expected, near ','. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:217) at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1635) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:426) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:372) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:6276) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1793) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:184) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:159) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:284) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70) ... 33 more {noformat} This is due to execution of this SQL-statement which is invalid for SQL-Server: {noformat} select employees0_.EmployeeGroup_departmentName as Employee1_2_1_, employees0_.EmployeeGroup_groupName as Employee2_2_1_, employees0_.employees_id as employee3_2_1_, employee1_.id as id1_0_0_, employee1_.name as name2_0_0_ from EmployeeGroup_Employee employees0_ inner join Employee employee1_ on employees0_.employees_id=employee1_.id where ( employees0_.EmployeeGroup_departmentName, employees0_.EmployeeGroup_groupName ) in ( select employeegr0_.departmentName, employeegr0_.groupName from EmployeeGroup employeegr0_ where employeegr0_.departmentName=? and employeegr0_.groupName=? or employeegr0_.departmentName=? and employeegr0_.groupName=? or employeegr0_.departmentName=? and employeegr0_.groupName=? ) {noformat}

    Hibernate JIRA | 8 months ago | Tobias Brueggemann
    org.hibernate.exception.SQLGrammarException: could not extract ResultSet
  3. 0

    count in Spring JPA

    Stack Overflow | 2 years ago | Aly González
    com.microsoft.sqlserver.jdbc.SQLServerException: An expression of non-boolean type specified in a context where a condition is expected, near ','.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Procedure's source not shown

    squirrel-sql | 1 year ago | skinny1973
    com.microsoft.sqlserver.jdbc.SQLServerException: The object 'procedure_name_1.2' does not exist in database 'myDB' or is invalid for this operation.

  1. muffinmannen 2 times, last 5 months ago
37 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. com.microsoft.sqlserver.jdbc.SQLServerException

    An expression of non-boolean type specified in a context where a condition is expected, near ','.

    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError()
  2. com.microsoft.sqlserver
    SQLServerPreparedStatement.executeQuery
    1. com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:217)
    2. com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1635)
    3. com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:426)
    4. com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:372)
    5. com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:6276)
    6. com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1793)
    7. com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:184)
    8. com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:159)
    9. com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:284)
    9 frames
  3. Hibernate
    PersistentBag.size
    1. org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70)
    2. org.hibernate.loader.Loader.getResultSet(Loader.java:2115)
    3. org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1898)
    4. org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1874)
    5. org.hibernate.loader.Loader.doQuery(Loader.java:919)
    6. org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336)
    7. org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:306)
    8. org.hibernate.loader.Loader.loadCollectionSubselect(Loader.java:2385)
    9. org.hibernate.loader.collection.SubselectCollectionLoader.initialize(SubselectCollectionLoader.java:63)
    10. org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:682)
    11. org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:75)
    12. org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:2004)
    13. org.hibernate.collection.internal.AbstractPersistentCollection$4.doWork(AbstractPersistentCollection.java:562)
    14. org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:246)
    15. org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:558)
    16. org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:131)
    17. org.hibernate.collection.internal.AbstractPersistentCollection$1.doWork(AbstractPersistentCollection.java:160)
    18. org.hibernate.collection.internal.AbstractPersistentCollection$1.doWork(AbstractPersistentCollection.java:145)
    19. org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:246)
    20. org.hibernate.collection.internal.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:144)
    21. org.hibernate.collection.internal.PersistentBag.size(PersistentBag.java:261)
    21 frames
  4. org.hibernate.test
    CompositeIdTypeBindingTest.testCompositeTypeBinding
    1. org.hibernate.test.subselect.CompositeIdTypeBindingTest.testCompositeTypeBinding(CompositeIdTypeBindingTest.java:78)
    1 frame
  5. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    4. java.lang.reflect.Method.invoke(Method.java:497)
    4 frames
  6. JUnit
    FrameworkMethod.invokeExplosively
    1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    3 frames
  7. A Hibernate O/RM Module
    ExtendedFrameworkMethod.invokeExplosively
    1. org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:45)
    1 frame
  8. JUnit
    FailOnTimeout$StatementThread.run
    1. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    2. org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    3. org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    4. org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:74)
    4 frames