[
http://opensource.atlassian.com/projects/hibernate/browse/HBX-755?page=co...
]
Max Rydahl Andersen commented on HBX-755:
-----------------------------------------
We need two things:
1) something that ensures mappedBy will not be enabled on both side when just doing
reverse engineering "blindly"
2) a way to override it (in reveng.xml)
#1 is probably easiest by saying "if no override, then enabled mappedBy if the other
side is not mappedBy" the downside is though that then the ordering of tables/columns
affects which side mappedBy is done for...
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