AsfK
AsfK

Reputation: 3476

null JsonNode object saved as "null" string using H2 DB

I have a DB entity, contains JsonNode

like this:

@JdbcTypeCode(3001)
private JsonNode callbackData;

And the scenario is callbackData = null

Our DB is postgres which save this field as NULL to the DB (as expected). But in the tests we are using H2 DB which saves it as a "null" string

from application.yml:

 datasource:
    url: jdbc:h2:mem:db;MODE=PostgreSQL;DB_CLOSE_DELAY=-1
    username: ---
    password: ---
    driverClassName: org.h2.Driver
  jpa:
    database: POSTGRESQL
    show-sql: false
    hibernate:
      ddl-auto: create-drop
    properties:
      hibernate:
        dialect: org.hibernate.dialect.H2Dialect
        physical_naming_strategy: org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy
    defer-datasource-initialization: true

The code is simple, just JPA.save:

enter image description here

Is there a way to save the field as null?

Upvotes: 0

Views: 59

Answers (0)

Related Questions