[hibernate-issues] [Hibernate-JIRA] Created: (HHH-4712) Field named "id" (but not an @Id) in a class referenced via join table leads to "Column 'col_1_1_' not found" when retrieving old versions

Simon MacMullen (JIRA) noreply at atlassian.com
Thu Dec 17 10:47:29 EST 2009


Field named "id" (but not an @Id) in a class referenced via join table leads to "Column 'col_1_1_' not found" when retrieving old versions
------------------------------------------------------------------------------------------------------------------------------------------

                 Key: HHH-4712
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4712
             Project: Hibernate Core
          Issue Type: Bug
          Components: envers
    Affects Versions: 3.5.0-Beta-2, 3.3.0.GA
            Reporter: Simon MacMullen
            Priority: Minor
         Attachments: envers-bug.tar.gz

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:



@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;
}



@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;
}


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list