我正在尝试将以下实体插入H2数据库以进行测试
@Entity
public class User {
@OneToMany(mappedBy = "userEntity",
...
)
private List<UserPropertiesEntity> props = null;
...
}
以下是属性实体。
@Entity
public class UserPropertiesEntity {
@ManyToOne()
@JoinColumn(name = "user_id")
private UserEntity userEntity = null;
@Convert(converter = ObjectToJsonJpaConverter.class)
private Object value = null;
}
类ObjectToJsonJpaConverter
将任何对象序列化为JSON。
这是我的测试用例的样子。
@RunWith(SpringRunner.class)
@DataJpaTest
public class UserRepositoryTest {
...
@Test
public void getAllData() {
UserEntity userEntity = createDummyUserEntity();
UserPropertiesEntity prop= new UserPropertiesEntity();
prop.setKeyName("key");
prop.setValue("abc");
dummyInstanceEntity.setParameters(Arrays.asList(prop));
}
}
这失败,但例外
...
Caused by: org.h2.jdbc.JdbcSQLException: Hexadecimal string contains non-hex character: """abc"""; SQL statement:
insert into user_properties (id, user_id, key_name, value) values (null, ?, ?, ?) -- (NULL, ?1, ?2, ?3) [90004-197]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
...
我在这里想念什么?