Home > other >  Hibernate 6 @Type annotation
Hibernate 6 @Type annotation

Time:01-01

I upgraded to Springboot 3.0 and in my hibernate entity class has something like:

    @Column(columnDefinition = "jsonb", nullable = false, updatable = true, name = "accounts") 
    @Type(type = "jsonb")
    private ArrayList<Account> accounts;

But I'm getting the exception 'Cannot resolve method 'type' since upgrading to Springboot 3.0 and moving to Jakarta persistence.

I need a replacement for com.vladmihalcea.hibernate.type.json.JsonBinaryType;

CodePudding user response:

I found the answer:

I had to use the lib:

<groupId>com.vladmihalcea</groupId> 
<artifactId>hibernate-types-60</artifactId> 

and in the entity:

    @Column(columnDefinition = "jsonb", nullable = false, updatable = true, name = "accounts") 
    @Type(JsonBinaryType.class)
    private ArrayList<Account> accounts;

CodePudding user response:

In Hibernate 6, the mapping annotations are much more typesafe. You're usually required to specify Class references instead of stringly-typed names.

  • Related