Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 对象作为JSON持久化_Java_Jpa_Datanucleus - Fatal编程技术网

Java 对象作为JSON持久化

Java 对象作为JSON持久化,java,jpa,datanucleus,Java,Jpa,Datanucleus,我有以下实体 @Entity public class MyEntity { @Lob @Convert(converter = JsonAttributeConverter.class) private Object data; } 我希望它作为字符串而不是二进制数组持久化。如果我把注释 @Column(name=“data”,columnDefinition=“mediumtext NOT NULL”)(我使用的是MySQL),然后在尝试持久化时,我得到由以下原因引起的错误:jav

我有以下实体

@Entity
public class MyEntity {
    @Lob @Convert(converter = JsonAttributeConverter.class)
private Object data;
}
我希望它作为字符串而不是二进制数组持久化。如果我把注释
@Column(name=“data”,columnDefinition=“mediumtext NOT NULL”)
(我使用的是MySQL),然后在尝试持久化时,我得到由以下原因引起的错误:java.sql.SQLException:不正确的字符串值:“\xAC\xED\x00\x05t\x07…”对于第1行的列“data”

问题是DataNucleus试图将其作为BLOB而不是CLOB持久化

这里有解决办法吗?(使用@PrePersist方法和附加字段除外)


我正在使用org.datanucleus:datanucleus accessplatform jpa rdbms:3.3.2。

为什么您不喜欢带有附加字段的
预持久化
的想法?尝试过使用datanucleus extension@JdbcType吗@AndreiI,因为模型将依赖于JSON库,在我看来,JSON库不是一个好的设计选择。@DataNucleus不,但我会,并让您知道结果。好的,但您已经遇到了这样一个问题,您依赖于DataNucleus(@Converter)注释。