我正在使用hibernate 5.1.0。
我有两个pojos:
@Table(name = "SCHEMA1.TABLEA")
public class OBJECTA implements Serializable {
private Collection<OBJECTB> objectsB = new ArrayList<>();
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "SCHEMA1.TABLEAB", joinColumns = { @JoinColumn(name = "IDA", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "IDB", nullable = false, updatable = false) })
@CollectionId(columns = @Column(name = "ID"), type = @Type(type = "long"), generator = "ABSEQ")
public Collection<OBJECTB> getObjectsB() {
return this.objectsB;
}
}
@Table(name = "SCHEMA1.TABLEB")
public class OBJECTB implements Serializable {
private Set<OBJECTA> objectsA;
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "objectsB")
public Set<OBJECTA> getObjectsA() {
return this.objectsA;
}
}
所有表格都存在:SCHEMA1.TABLEA,SCHEMA1.TABLEB和SCHEMA1.TABLEAB。
每个SELECT都在我的应用程序中工作,但是当我尝试执行INSERT或UPDATE向我的OBJECTA添加OBJECTB集合时,它会崩溃并出现下一个错误:
ORA-00942: table or view does not exist
但是我可以插入或更新OBJECTA或OBJECTB,而不包含其他类的集合。
我想我的映射中有错误,但我看不出错误。
记录器没有向我显示SQL:
Hibernate: insert into SCHEMA1.TABLEA (DESC, NAME, ID) values (?, ?, ?)
2016-11-21 13:01:51,471 DEBUG [org.hibernate.persister.collection.AbstractCollectionPersister:1253] - <Inserting collection: [domain.myapp.OBJECTA.objectsA#42]>
2016-11-21 13:01:51,471 DEBUG [org.hibernate.SQL:92] - <select ABSEQ.nextval from dual>
Hibernate: select ABSEQ.nextval from dual
2016-11-21 13:01:53,891 DEBUG [org.hibernate.engine.jdbc.spi.SqlExceptionHelper:124] - <could not extract ResultSet [n/a]>
java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist