Hi,
I'm getting the next exception
Caused by: java.sql.SQLException: Integrity constraint violation - no parent FK383D52B87BA459A7 table: C in statement [insert into A (id, creation_time, description, version, file_extension, document_name, document_type, entity_id, entity_type, real_path) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?)]
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:57)
At the next usage:
1)I have an entity A:
Code:
public class A{
private String name;
private Long entityId;
private String entityType;
@Column(name = "entity_id")
public Long getEntityId() {
return entityId;
}
public void setEntityId(Long entityId){
this.entityId=entityId;
}
@Column(name = "entity_type")
public String getEntityType() {
return entityType;
}
public void setEntityType(String entityType) {
this.entityType = entityType;
}
}
2)Now, I want to map another two entities to the A entity, refering to the entityId and the entityType
here is the code for both of hte entities:
Code:
public class B{
........
........
........
Set<A> As;
@OneToMany()
@JoinColumn(name = "entity_id", referencedColumnName = "id")
@Where(clause = "entity_type = 'B'")
@OrderBy("creationTime DESC")
public Set<A> getAs() {
return As;
}
public void setAs(Set<A> As) {
this.As = As;
}
}
//=====================================================
public class B{
........
........
........
Set<A> As;
@OneToMany()
@JoinColumn(name = "entity_id", referencedColumnName = "id")
@Where(clause = "entity_type = 'C'")
@OrderBy("creationTime DESC")
public Set<A> getAs() {
return As;
}
public void setAs(Set<A> As) {
this.As = As;
}
}
Just making clear :
1) When I use the
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver
There is no issue at all, everything goes smooth.
The problem is when I use :
hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.connection.driver_class=org.hsqldb.jdbcDriver.
2)When I remove one of B or C there is no issue.