Issue Type: Bug Bug
Affects Versions: 4.1.4
Assignee: Unassigned
Components: envers
Created: 06/Jul/12 3:31 PM
Description:

I'm using the latest Hibernate version with Envers support. I have two classes containing a One-To-Many and a Many-To-One relationship:

Code:
@Entity
@Audited(withModifiedFlag = true)
class A { @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "a") private List<B> bees; }

@Entity
@Audited(withModifiedFlag = true)
class B { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "aId") private A a; }

When saving object A with a list of B object a got the following exception: (updating an object is no problem)

java.lang.ClassCastException: java.util.ArrayList cannot be cast to org.hibernate.collection.spi.PersistentCollection
at org.hibernate.envers.entities.mapper.relation.AbstractCollectionMapper.mapModifiedFlagsToMapFromEntity(AbstractCollectionMapper.java:142)
at org.hibernate.envers.entities.mapper.MultiPropertyMapper.map(MultiPropertyMapper.java:89)
at org.hibernate.envers.synchronization.work.AddWorkUnit.<init>(AddWorkUnit.java:49)

I think the problem is that Envers is trying to track the changes on the collection because it wants to save the audit trail record but the collection is not yet persisted to the database.

Environment: Mysql
Project: Hibernate ORM
Priority: Major Major
Reporter: Jethro Bakker
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