After running JUnit test [while commiting] i got this exception:
Caused by: org.hibernate.HibernateException: cannot recreate collection while filter is enabled: .......OrgUnit.children#4]
I have filter enabled at the OrgUnit entity itself:
Code:
@Filter(name=FilterConstant.NOT_CANCELED_ITEMS, condition="state <> 'CANCELED'")
and also at child definition:
Code:
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinTable(name = "Parent_Child_OU",
joinColumns = @JoinColumn(name = "childId", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "parentId", referencedColumnName = "id"))
private List<OrgUnit> parents;
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "parents")
@Filter(name=FilterConstant.NOT_CANCELED_ITEMS, condition="state <> 'CANCELED'")
private List<OrgUnit> children;
Is it needed to specify @IndexColumn at children property? (requires some more work at inserts)
Is there any other solution?
Am I doing some mistake?
I use Hibernate 4.1.4.Final, though i expect this to be version independent.
Any answers would be greatly appreciated.