[hibernate-issues] [Hibernate-JIRA] Commented: (HBX-1093) Missing inverseJoinColumn at ManyToMany relations with composite keys

Vitali Yemialyanchyk (JIRA) noreply at atlassian.com
Wed Jan 21 11:38:39 EST 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HBX-1093?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32171#action_32171 ] 

Vitali Yemialyanchyk commented on HBX-1093:
-------------------------------------------

I could try to fix this.

> Missing inverseJoinColumn at ManyToMany relations with composite keys
> ---------------------------------------------------------------------
>
>                 Key: HBX-1093
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1093
>             Project: Hibernate Tools
>          Issue Type: Bug
>          Components: hbm2java
>    Affects Versions: 3.2.2, 3.2LATER
>         Environment: Hibernate Tools version 3.2.2.Beta1 and 3.2.4.CR1-N200810300202, Oracle Database
>            Reporter: Nils Kelleter
>
> Using the hbm2java tool for reverse engineering of database tables, the following problem exists: 
> At ManyToMany relations with composite keys an inverseJoinColumn is missing. 
> Wrong code: 
> @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) 
> @JoinTable(name = "ET_MANY_TO_MANY_COMP_MAPPING", 
> joinColumns = { 
> @JoinColumn(name = "FK_ET_MANY_TO_MANY_COMP1_ID", nullable = false, updatable = false), 
> @JoinColumn(name = "FK_ET_MANY_TO_MANY_COMP11_ID", nullable = false, updatable = false) }, 
> inverseJoinColumns = { 
> @JoinColumn(name = "FK_ET_MANY_TO_MANY_COMP2_ID", nullable = false, updatable = false) }) 
> public Set<EtManyToManyComp2> getEtManyToManyComp2s() { 
>     return this.etManyToManyComp2s; 
> } 
> @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) 
> @JoinTable(name = "ET_MANY_TO_MANY_COMP_MAPPING", 
> joinColumns = { 
> @JoinColumn(name = "FK_ET_MANY_TO_MANY_COMP2_ID", nullable = false, updatable = false), 
> @JoinColumn(name = "FK_ET_MANY_TO_MANY_COMP22_ID", nullable = false, updatable = false) }, 
> inverseJoinColumns = { 
> @JoinColumn(name = "FK_ET_MANY_TO_MANY_COMP1_ID", nullable = false, updatable = false) }) 
> public Set<EtManyToManyComp1> getEtManyToManyComp1s() { 
>    return this.etManyToManyComp1s; 
> } 
> Correct code: 
> @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) 
> @JoinTable(name = "ET_MANY_TO_MANY_COMP_MAPPING", 
> joinColumns = { 
> @JoinColumn(name = "FK_ET_MANY_TO_MANY_COMP1_ID", nullable = false, updatable = false), 
> @JoinColumn(name = "FK_ET_MANY_TO_MANY_COMP11_ID", nullable = false, updatable = false) }, 
> inverseJoinColumns = { 
> @JoinColumn(name = "FK_ET_MANY_TO_MANY_COMP2_ID", nullable = false, updatable = false), 
> @JoinColumn(name = "FK_ET_MANY_TO_MANY_COMP22_ID", nullable = false, updatable = false) }) 
> public Set<EtManyToManyComp2> getEtManyToManyComp2s() { 
>     return this.etManyToManyComp2s; 
> } 
> @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) 
> @JoinTable(name = "ET_MANY_TO_MANY_COMP_MAPPING", 
> joinColumns = { 
> @JoinColumn(name = "FK_ET_MANY_TO_MANY_COMP2_ID", nullable = false, updatable = false), 
> @JoinColumn(name = "FK_ET_MANY_TO_MANY_COMP22_ID", nullable = false, updatable = false) }, 
> inverseJoinColumns = { 
> @JoinColumn(name = "FK_ET_MANY_TO_MANY_COMP1_ID", nullable = false, updatable = false), 
> @JoinColumn(name = "FK_ET_MANY_TO_MANY_COMP11_ID", nullable = false, updatable = false) }) 
> public Set<EtManyToManyComp1> getEtManyToManyComp1s() { 
>    return this.etManyToManyComp1s; 
> } 
> For reproducing this, you can use the following Oracle SQL scripts: 
> CREATE TABLE ET_MANY_TO_MANY_COMP1 ( 
> ET_MANY_TO_MANY_COMP1_ID NUMBER, 
> ET_MANY_TO_MANY_COMP11_ID NUMBER, 
> FIELD VARCHAR2(10), 
> PRIMARY KEY (ET_MANY_TO_MANY_COMP1_ID, ET_MANY_TO_MANY_COMP11_ID) 
> ); 
> CREATE TABLE ET_MANY_TO_MANY_COMP2 ( 
> ET_MANY_TO_MANY_COMP2_ID NUMBER, 
> ET_MANY_TO_MANY_COMP22_ID NUMBER, 
> FIELD   VARCHAR2(10), 
> PRIMARY KEY (ET_MANY_TO_MANY_COMP2_ID, ET_MANY_TO_MANY_COMP22_ID) 
> ); 
> CREATE TABLE ET_MANY_TO_MANY_COMP_MAPPING ( 
> FK_ET_MANY_TO_MANY_COMP1_ID NUMBER, 
> FK_ET_MANY_TO_MANY_COMP11_ID NUMBER, 
> FK_ET_MANY_TO_MANY_COMP2_ID NUMBER, 
> FK_ET_MANY_TO_MANY_COMP22_ID NUMBER, 
> FOREIGN KEY (FK_ET_MANY_TO_MANY_COMP1_ID,FK_ET_MANY_TO_MANY_COMP11_ID) 
>   REFERENCES ET_MANY_TO_MANY_COMP1(ET_MANY_TO_MANY_COMP1_ID,ET_MANY_TO_MANY_COMP11_ID), 
> FOREIGN KEY (FK_ET_MANY_TO_MANY_COMP2_ID, FK_ET_MANY_TO_MANY_COMP22_ID) 
>   REFERENCES ET_MANY_TO_MANY_COMP2(ET_MANY_TO_MANY_COMP2_ID, ET_MANY_TO_MANY_COMP22_ID), 
> PRIMARY KEY (FK_ET_MANY_TO_MANY_COMP1_ID,FK_ET_MANY_TO_MANY_COMP11_ID,FK_ET_MANY_TO_MANY_COMP2_ID,FK_ET_MANY_TO_MANY_COMP22_ID) 
> ); 

-- 
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