Skip to content

Instantly share code, notes, and snippets.

@johnrengelman
Created October 29, 2013 18:30
Show Gist options
  • Save johnrengelman/7220090 to your computer and use it in GitHub Desktop.
Save johnrengelman/7220090 to your computer and use it in GitHub Desktop.
Custom H2 Hibernate Dialect to support differences in MySQL and H2 query syntax
import org.hibernate.dialect.H2Dialect
import org.hibernate.dialect.function.SQLFunctionTemplate
import org.hibernate.type.StandardBasicTypes
class H2MysqlSupportDialect extends H2Dialect {
H2MysqlSupportDialect() {
registerFunction('datediff', new SQLFunctionTemplate(StandardBasicTypes.DATE, "datediff('DAY', ?2, ?1)"))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment