Issue Type: New Feature New Feature
Affects Versions: 4.1.8, 4.1.0
Assignee: Unassigned
Components: envers
Created: 16/Nov/12 1:52 AM
Description:

List<Object[]> results = query.getResultList();
for (Object[] result : results)

{ CustomRevisionEntity rev = (CustomRevisionEntity)result[1]; em.remove(rev); }

This deletion causes a violation of foreign key constraint for every Audit-table of each entity annotated with @Audited.

I think that's because the the Audit-table for each entity and the RevisionChanges-table are created and altered by hbm2dll with these statements:
"create table REVCHANGES(RevId number(19,0) not null,EntityName varchar2(255 char));"

"alter table REVCHANGES add constraint FKD33F46C4B65ED994 foreign key (RevId) references REVINFO;"

To work this around I alter all these tables again by adding "ON DELETE CASCADE" to the foreign key constraint, e.g.:
"alter table REVCHANGES drop constraint FKD33F46C4B65ED994;"
"alter table REVCHANGES add constraint FKD33F46C4B65ED994 foreign key (RevId) references REVINFO ON DELETE CASCADE;"

There should be a possibility to set the cascade for an @Audited Entity, maybe in the annotation.

Project: Hibernate ORM
Labels: hibernate
Priority: Major Major
Reporter: Philipp Berger
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira