Unable to instantiate AttributeConverter for JsonBinaryType

2.5k Views Asked by At

I have recently upgraded my springboot version to 3.0.2. Also, the hibernate dependencies were upgraded to 6.1.6.Final. I am using hibernate-type 60 from hypersistence util.

<dependency>
      <groupId>org.hibernate.orm</groupId>
      <artifactId>hibernate-core</artifactId>
      <scope>compile</scope>
      <version>6.1.6.Final</version>
    </dependency>
    
    <dependency>
        <groupId>io.hypersistence</groupId>
        <artifactId>hypersistence-utils-hibernate-60</artifactId>
        <version>3.2.0</version>
    </dependency>

After upgrading, I am unable to create bean on JsonBinaryType column. I am using this column to store json object as jsonb structure in my postgresql database. But, I receive the below exception:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unable to instantiate AttributeConverter [io.hypersistence.utils.hibernate.type.json.JsonBinaryType]
Caused by: java.lang.IllegalStateException: Unable to instantiate AttributeConverter [io.hypersistence.utils.hibernate.type.json.JsonBinaryType]
Caused by: org.hibernate.AnnotationException: Unable to create AttributeConverter instance
Caused by: org.hibernate.AnnotationException: Could not extract type argument from attribute converter class 'io.hypersistence.utils.hibernate.type.json.JsonBinaryType'

Code with hibernate-type-52 dependency

@Entity
@Table(name = "test_table")
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
public class TestTable implements Serializable {

  private static final long serialVersionUID = 1L;

  @Type(type = "jsonb")
  @Column(name = "payload_data", columnDefinition = "jsonb")
  private Object payload;
}

Code after upgrading to hypersistence-utils-hibernate-60 dependency

 @Entity
    @Table(name = "test_table")
    public class TestTable implements Serializable {
    
      private static final long serialVersionUID = 1L;
    
      @Convert(converter = JsonBinaryType.class)
      @Column(name = "payload", columnDefinition = "jsonb")
      private Object payload;
    }

What am I missing here. How can I fix this issue, need help on this.

-Thanks Srikant Mantha

0

There are 0 best solutions below