[JAVA] Add quotation marks when specifying NULL for JdbcTypeForNull in application.yml

As the title says. It's a simple thing, but I'm addicted to it, so I'll write it down.

environment

How to set JdbcTypeForNull in application.yml

If you specify NULL as a value in yaml, it will be treated as a null value when reading. If you want to set the value of JdbcTypeForNull to JdbcType.NULL, you need to specify'NULL' with quotation marks in application.yml.

application.yml


mybatis:
  configuration:
    jdbc-type-for-null: 'NULL'

By the way, in the case of a property file, the value is always treated as a string, so no quotations are needed

application.properties


mybatis.configuration.jdbc-type-for-null=NULL

About JdbcTypeForNull

When setting a DB column to null, you must specify a null value and a JDBC type mapping. Mybatis is set to specify JdbcType.OTHER by default, but some JDBC drivers such as Oracle do not support JdbcType.OTHER, so the default setting causes an error. .. In case of Oracle, it seems to be solved by specifying JdbcType.NULL.

Reference URL

-MyBatis – MyBatis 3 \ | Settings

Recommended Posts

Add quotation marks when specifying NULL for JdbcTypeForNull in application.yml
Precautions when specifying the URL in render