Hibernate Error: @P0 Syntax Error

Posted 05/18/2017 6:02 PM by Corey Klass

Grails domain classes using GORM offer the dynamic finders Class.findByXXX() and Class.findAllByXXX(max: 123), which will retrieve 1 record and 123 records, respectively.

On SQL Server 2012 or higher, attempting to call one of these functions will throw a Hibernate error "Invalid syntax @p0". This is because you need to add an additional configuration option to your /grails-app/conf/application.yml file dataSource section:

dialect: org.hibernate.dialect.SQLServer2012Dialect