mysqlhibernatesql-mode

How to set sql_mode hibernate


Is there a way to set the sql_mode (for MySql database) in Hibernate properties or in connection string?

Thanks,

Stefano


Solution

  • Yes, as documented sessionVariables property which is defined as follows can be used in JDBC connection string:

    A comma-separated list of name/value pairs to be sent as SET SESSION ... to the server when the driver connects.

    List of values goes inside single quotes:

    sessionVariables=sql_mode='ALLOW_INVALID_DATES,NO_BACKSLASH_ESCAPES'