[
http://opensource.atlassian.com/projects/hibernate/browse/HBX-755?page=co...
]
Robert Banfill commented on HBX-755:
------------------------------------
This is really all about the default behaviors of the core and the tool. When we
'blindly' reverse engineer a database, we would like to the tool to generate code
that observes the default behavior of the core so that we do not have to edit or otherwise
modify the annotations in the entity classes at all. This means that the tool needs to
assume that many-to-many association tables are named 'owning_inverse' and place a
single 'mappedBy' on the inverse end of the relationship by default. This
behavior then matches the default expectations of core and at runtime things are happy.
Of course, this assumes that the association tables are named using this convention and
further, that the columns are appropriately named as well so that Hibernate core will like
it at runtime by default. In our case, we control data models, so this is not an issue.
If the data model cannot be controlled, there should be some kind of override(s) in the
reverse engineering file and elsewhere for the core to make things happy in this case.
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