1

There is field of json type in postgres db named data_processing_steps. It's defined in category entity as

    @Type(JsonType.class)
    @Column(columnDefinition = "json")
    private Set<DataProcessingStep> dataProcessingSteps = new HashSet<>();

fly way migration:

ALTER TABLE category ADD COLUMN IF NOT EXISTS data_processing_steps json not null default '[]'::json;

On entity save, I'm getting the error:

[ERROR: column "data_processing_steps" is of type json but expression is of type smallint[]

sql logs:

DEBUG org.hibernate.SQL[135] - insert into category (active,label,created_by,created_date,data_processing_steps) values (?,?,?,?,?)
2024-07-08 22:11:01.087 [main] TRACE org.hibernate.orm.jdbc.bind[24] - binding parameter (1:BOOLEAN) <- [true]
2024-07-08 22:11:01.087 [main] TRACE org.hibernate.orm.jdbc.bind[24] - binding parameter (2:VARCHAR) <- [label1]
2024-07-08 22:11:01.087 [main] TRACE org.hibernate.orm.jdbc.bind[24] - binding parameter (3:VARCHAR) <- [[email protected]]
2024-07-08 22:11:01.087 [main] TRACE org.hibernate.orm.jdbc.bind[24] - binding parameter (4:TIMESTAMP_UTC) <- [2024-07-08T22:11:01.087618+03:00]
2024-07-08 22:11:01.088 [main] TRACE org.hibernate.orm.jdbc.bind[24] - binding parameter (5:ARRAY) <- [[]]
3
  • 2
    What and how exactly you're trying to serialize isn't shown but my bet would be that it probably needs to be converted. Also, if you prefer speed and space efficiency over whitespace and duplicated, un- or custom-ordered keys, use jsonb.
    – Zegarek
    Commented Jul 8 at 20:53
  • Hi @Zegarek. Thank you for reply! I'm not using any extra serializer. Commented Jul 9 at 5:16
  • @LeshaPipiev which Hibernate version do you use? 5 or 6?
    – Eric
    Commented Jul 10 at 13:24

0

Browse other questions tagged or ask your own question.