Object persisted as JSON

391 views Asked by At

I have the following entity

@Entity
public class MyEntity {
    @Lob @Convert(converter = JsonAttributeConverter.class)
private Object data;
}

I want this persisted as a string not binary array. If I put the annotation @Column(name="data", columnDefinition="mediumtext NOT NULL") (I'm using MySQL), then when trying to persist I get the error Caused by: java.sql.SQLException: Incorrect string value: '\xAC\xED\x00\x05t\x07...' for column 'data' at row 1

The problem is that DataNucleus tries to persist this as a BLOB instead of CLOB.

Is there any workaround here? (except using a @PrePersist method and an additional field)

I'm using org.datanucleus:datanucleus-accessplatform-jpa-rdbms:3.3.2.

0

There are 0 answers