Embracing the Messiness in Search of Epic Solutions

MS SQL Server + Hibernate 5: Incorrect syntax near ‘@P0’

Posted

in

,

PROBLEM

When upgrading to Hibernate 5, the following exception is thrown:-

Caused by: java.sql.SQLException: Incorrect syntax near '@P0'.
	at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:372) ~[jtds-1.3.1.jar:1.3.1]
	at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2988) ~[jtds-1.3.1.jar:1.3.1]
	at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2421) ~[jtds-1.3.1.jar:1.3.1]

SOLUTION

Change the MS SQL Server dialect from this…

org.hibernate.dialect.SQLServerDialect

… to this …

org.hibernate.dialect.SQLServer2012Dialect

Comments

3 responses to “MS SQL Server + Hibernate 5: Incorrect syntax near ‘@P0’”

  1. ashishkirpan Avatar

    Thanks…you save my day.

  2. saurabh Avatar
    saurabh

    Thanks raaa

  3. John Corkett Avatar

    Thank you so much. I have spent half a day on this. before I realised that it wasn’t my code that was at fault.

Leave a Reply