[hibernate-issues] [Hibernate-JIRA] Commented: (HBX-755) incorrect genreated code for many-to-many relationship
Max Rydahl Andersen (JIRA)
noreply at atlassian.com
Wed Nov 1 14:03:05 EST 2006
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-755?page=comments#action_25064 ]
Max Rydahl Andersen commented on HBX-755:
-----------------------------------------
if you remove the mapped-by on one of the sides the code will work (assuming you have the latest version that actually put the table name into the annotaitons). Why wouldn't it ?
And yes, blindly pointing to the db will almost always generate non-optimal mappings, but I still would like it to at least work....alternatively we can decide to disable many-to-many detection by default thus it will not be a problem unless people ask for it.
> 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.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list