I have a child class referenced with a @OneToMany via a @JoinTable. This class has a field in it named "id", as well as a real @Id field called something else.
Envers seems to treat the field specially because it's called "id", which seems wrong. It seems to get confused and ends up trying to pull a column from a ResultSet which did not exist in the appropriate query.
I've attached a small test case. Run "mvn install" and the test case will throw an exception. Rename the field Child.id to anything else and "mvn install" will succeed.
The pom in the test case references 3.3.2.GA and Envers 1.2.0.GA-hibernate-3.3, but I've tried with 3.5.0.Beta-2 and got exactly the same result.
To save opening the tarball if you don't want to run it, the entity classes look like this:
{code:title=Parent.java} @Entity @Audited public class Parent {
@GeneratedValue(generator="sequence_generator") @GenericGenerator(name="sequence_generator", strategy="org.hibernate.id.enhanced.SequenceStyleGenerator") @Id public int id = 0;
@OneToMany(cascade = CascadeType.ALL) @JoinTable(name = "join_table", joinColumns = @JoinColumn(name="parent_id"), inverseJoinColumns = @JoinColumn(name="child_id")) public List<Child> children; } {code} {code:title=Child.java} @Entity @Audited public class Child { @GeneratedValue(generator="sequence_generator") @GenericGenerator(name="sequence_generator", strategy="org.hibernate.id.enhanced.SequenceStyleGenerator") @Id public int theRealId = 0;
// This is the problematic field - rename it to anything other than "id" and the test will pass. public int id = 0; } {code} |
|