org.hsqldb.HsqlException: integrity constraint violation: NOT NULL check constraint; SYS_CT_* table: CATEGORY_RELATIONS column: CATEGORY_RELATIONS_ID
I think, wtih current autogeneration annotation for CATEGORY_RELATIONS_ID, it can not be null, but it is.
How this situation can be fixed?
getSessionFactory().save(category);
//...
@Entity
@Table(name = "CATEGORY")
public class Category {
@Id
@Column(name = "CATEGORY_ID")
@GeneratedValue(strategy = GenerationType.AUTO)
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "CATEGORY_RELATIONS",
joinColumns = {@JoinColumn(name = "CATEGORY_RELATIONS_CATEGORY_ID", referencedColumnName = "CATEGORY_ID")},
inverseJoinColumns = {@JoinColumn(name = "CATEGORY_RELATIONS_PARENT_ID", referencedColumnName = "CATEGORY_ID")})
private Category parent;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "parent")
//........................................
@Entity
@Table(name = "CATEGORY_RELATIONS")
public class CategoryRelations {
@Id
@Column(name = "CATEGORY_RELATIONS_ID")
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name = "CATEGORY_RELATIONS_CATEGORY_ID")
private String categoryId;
@Column(name = "CATEGORY_RELATIONS_PARENT_ID")
private String parentId;
INTEGRITY listener:
public class HSqlTestExecutionListener extends AbstractTestExecutionListener {
@Override
public void beforeTestClass(TestContext testContext) throws Exception {
IDatabaseConnection databaseDataSourceConnection = new DatabaseDataSourceConnection(
testContext.getApplicationContext().getBean(DataSource.class)
);
databaseDataSourceConnection.getConnection().prepareStatement(
"SET DATABASE REFERENTIAL INTEGRITY FALSE").execute();
}
}
Aucun commentaire:
Enregistrer un commentaire