I have a SpringBoot project which persists data to a Postgres JsonB Column. So I am using the @TypeDef annotation in entity class, but after upgrading to SpringBoot Version 3.1.5 this annotation is no longer available.
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.annotations.Type;
//import org.hibernate.type.SqlTypes;
import org.json.simple.JSONObject;
@Entity
@Table(name = "myTable")
@TypeDef(name = "jsonb", typeClass = JsonBinaryType::class) // Typedef is not available
data class MyEntity(
@Id
@Column(unique = true, nullable = false, updatable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
@Type(type = "jsonb")
@Column(nullable = true)
private JSONObject objConfig;
)
I tried using @JdbcTypeCode(SqlTypes.JSON) instead of @Type but at runntime I am getting
Could not write JSON: Can't resolve required map value type for class org.json.simple.JSONObject
I tried hibernate-core 6.1.6.Final too
I have solved it as: Using Map instead of JSON OBject