[
http://opensource.atlassian.com/projects/hibernate/browse/HBX-755?page=co...
]
Robert Banfill commented on HBX-755:
------------------------------------
Correct me if I'm wrong, but it seems to me that when one 'blindly' reverse
engineers a database, that database must adhere to the conventions described above in
order to generate code that will run.
One is free to have association tables that consist of two foreign keys comprising a
composite primary key and name things whatever one likes. The tool will generate code
that compiles but after removing the 'mappedBy' for the owning end of that
many-to-many this code will not run do to the default behavior of core.
I can't see how one will ever be able to simply point the reverse engineering tool at
a database that has many-to-many association tables that do not adhere to the default
conventions described above and get code that will run without further configuration
and/or tweaking.
Is there something I'm missing here?
incorrect genreated code for many-to-many relationship
-------------------------------------------------------
Key: HBX-755
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HBX-755
Project: Hibernate Tools
Type: Bug
Components: ant
Versions: 3.2beta7
Reporter: azamjalali
The following code is generated for Table rolea and roleb( these tables have many-to-many
relation). Both of entities use ManytoMany annotation without jointable annotation.
/////////////////////////////////////////////////////////////////////
package trce.impr.subsystem.entity;
// Generated Sep 17, 2006 1:04:06 AM by Hibernate Tools 3.2.0.beta7
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
/**
* RoleB generated by hbm2java
*/
@Entity
@Table(name="roleb"
,catalog="registration"
, uniqueConstraints = { }
)
public class RoleB implements java.io.Serializable {
// Fields
private int rolebId;
private Set<RoleA> roleas = new HashSet<RoleA>(0);
// Constructors
/** default constructor */
public RoleB() {
}
/** minimal constructor */
public RoleB(int rolebId) {
this.rolebId = rolebId;
}
/** full constructor */
public RoleB(int rolebId, Set<RoleA> roleas) {
this.rolebId = rolebId;
this.roleas = roleas;
}
// Property accessors
@Id
@Column(name="roleb_id", unique=true, nullable=false, insertable=true,
updatable=true)
public int getRolebId() {
return this.rolebId;
}
public void setRolebId(int rolebId) {
this.rolebId = rolebId;
}
@ManyToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY,
mappedBy="rolebs")
public Set<RoleA> getRoleas() {
return this.roleas;
}
public void setRoleas(Set<RoleA> roleas) {
this.roleas = roleas;
}
}
////////////////////////////////////////////////////////////////////////////////////
package trce.impr.subsystem.entity;
// Generated Sep 17, 2006 1:04:06 AM by Hibernate Tools 3.2.0.beta7
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
/**
* RoleA generated by hbm2java
*/
@Entity
@Table(name="rolea"
,catalog="registration"
, uniqueConstraints = { }
)
public class RoleA implements java.io.Serializable {
// Fields
private int roleaId;
private Set<RoleB> rolebs = new HashSet<RoleB>(0);
// Constructors
/** default constructor */
public RoleA() {
}
/** minimal constructor */
public RoleA(int roleaId) {
this.roleaId = roleaId;
}
/** full constructor */
public RoleA(int roleaId, Set<RoleB> rolebs) {
this.roleaId = roleaId;
this.rolebs = rolebs;
}
// Property accessors
@Id
@Column(name="rolea_id", unique=true, nullable=false, insertable=true,
updatable=true)
public int getRoleaId() {
return this.roleaId;
}
y
public void setRoleaId(int roleaId) {
this.roleaId = roleaId;
}
@ManyToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY,
mappedBy="roleas")
public Set<RoleB> getRolebs() {
return this.rolebs;
}
public void setRolebs(Set<RoleB> rolebs) {
this.rolebs = rolebs;
}
}
//////////////////////////////////////////////////////////////////////
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira