org.hibernate.mappingexception:无法确定以下列的类型:org.json.jsonarray,位于table:book:[org.hibernate.mapping.column(people)]

qvsjd97n  于 2021-06-21  发布在  Mysql
关注(0)|答案(0)|浏览(251)

我正在用mysql和jpa开发一个spring启动库应用程序。数据库表由以下列组成:bookname、author、copiestotal、copiesavailable、people。问题在于jsonobject列“people”。我想用“人”栏来存储借阅某本书的人的详细信息。
“people”列例如:{“john”:“9876543210”,“mark”:“0123456789”}
我应该使用任何注解还是代码中有错误?
这是我的密码。
书籍.java

@Entity
public class Book {

@Id
@Column(name="bookName")
private String bookName;

@Column(name="author")
private String author;

@Column(name="copiesTotal")
private int    copiesTotal;

@Column(name="copiesAvailable")
private int    copiesAvailable;

@Column(name="people")
//should we use any other annotation here?
private JSONObject people;
//setters and getters omitted

public Book() {

}

public Book(String bookName, String author, int copiesTotal, int copiesAvailable, JSONObject people) {
    super();
    this.bookName = bookName;
    this.author = author;
    this.copiesTotal = copiesTotal;
    this.copiesAvailable = copiesAvailable;
    this.people = people;

}

慰问:

Caused by: org.hibernate.MappingException: Could not determine type for: org.json.JSONObject, at table: book, for columns: [org.hibernate.mapping.Column(people)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:431) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:398) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.mapping.Property.isValid(Property.java:225) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:595) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.mapping.RootClass.validate(RootClass.java:265) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:329) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:443) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
... 23 common frames omitted

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题