ERROR Incorrect syntax near hibernate

Working with Hibernate and while calling the stored procedure you get exception “ERROR: Incorrect syntax near ‘.'” details of exception below:

Hibernate: CALL OTC.dbo.TestStoreProcedure(?)
Dec 27, 2015 3:35:40 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 102, SQLState: 42000
Dec 27, 2015 3:35:40 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: Incorrect syntax near '.'.
  • Solution: Best way to debug this issue to enable to see what SQL is getting fired as below:
<property name="hibernate.show.sql" value="true"></property>

Once show SQl property is enabled you could see what query is getting fired and if anything wrong with that query. For example in my case I was using the stored procedure as named query to get the data but “{}” was missing as below:

  • Missing {}:

ERROR Incorrect syntax near hibernate

  • Corrected:

ERROR Incorrect syntax near hibernate

Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *