Help

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

After using the reverse engineering tool in seam-gen or JBoss Tools, you may notice duplicate associations showing up in your entity classes and UI screens. An example of the problem is shown here.

private Set<Vehicle> vehicles_1 = new HashSet<Vehicle>(0);

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "person")
public Set<Vehicle> getVehicles_1() {
    return this.vehicles_1;
}
    
public void setVehicles_1(Set<Vehicle> vehicles_1) {
    this.vehicles_1 = vehicles_1;
}

When you create a project using seam-gen, the Hibernate schema behavior is set to update, defined by the property hibernate.hbm2ddl.auto. This causes Hibernate to execute the SchemaUpdate task when the application starts. The extra associations are the effect of a bug (HHH-3532) in Hibernate's SchemaUpdate task. The schema tool was failing to identify existing foreign keys and would therefore add duplicate foreign keys to the table. When the reverse engineering tool subsequently runs, it creates an association for each foreign key.

A fix has been proposed for this issue (and may have already been accepted). However, since Hibernate is bundled with JBoss AS, you will need to either compile your own or download a version to which this fix is applied and copy hibernate3.jar to the lib folder of your JBoss AS domain (e.g., server/default/lib).

Another solution is to simply change the default value of the hibernate.hbm2ddl.auto property from update to none or validate.