Reputation: 813
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;
Upvotes: 14
Views: 23907
Reputation: 81
In Hybernate 6, new features have been added like the SqlTypes.JSON
. So, you could have "jsonb" in your field like this:
@JdbcTypeCode(SqlTypes.JSON)
@Column(columnDefinition = "jsonb")
private ArrayList<Account> accounts;
Upvotes: 8
Reputation: 16400
If you want to model JSON, I would suggest you to use @JdbcTypeCode(SqlTypes.JSON)
which is how you model JSON with plain Hibernate ORM Core. Also see https://docs.jboss.org/hibernate/orm/6.1/userguide/html_single/Hibernate_User_Guide.html#basic-mapping-json
Upvotes: 2
Reputation: 4263
In Hibernate 6, the mapping annotations are much more typesafe. You're usually required to specify Class
references instead of stringly-typed names.
Upvotes: 5
Reputation: 813
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;
Upvotes: 9