facebook

Incorrect mappedBy relation in entities – urgent

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #343000 Reply

    creddy2001
    Member

    Hi

    We are using this tool to generate entities and DAO’s from database. It is not generating the relations correctly when there are two or more foreginKey relations from one table to another table.

    I have fedemployee table primarykey, createdby and modifiedby etc columns. createdby and modifiedby are referenced to the primarykey on the same table. It is generating relation ship with invalid mappedby. both has same mappedby value. Please see the generated code below.

    /**
    */
    @OneToMany(mappedBy = “fedemployeeByLastmodifiedby”, cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
    @XmlElement(name = “”, namespace = “”)
    private java.util.Set<org.frb.scar.entity.Fedemployee> fedemployeesForCreatedby;

    /**
    */
    @OneToMany(mappedBy = “fedemployeeByLastmodifiedby”, cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
    @XmlElement(name = “”, namespace = “”)
    private java.util.Set<org.frb.scar.entity.Fedteamprofileassociation> fedteamprofileassociationsForCreatedby;

    #343005 Reply

    creddy200,

    Sorry that you are facing this issue.

    To help us investigate further, can you please share some more information :
    1) Can you please share your MyEclipse installation details from MyEclipse > Installation summary > Installation details ?
    2) Can you please mention the database name and version you are working on ?
    3) To help us replicate the issue at our end, can you please copy paste the schema of the tables on which you are trying to generate entities and DAO’s ?

    #343040 Reply

    creddy2001
    Member

    Hi Pradeep

    Thank you very much for quick response. Here are the requested details.

    1. Installation details
    ———————————————————–
    *** Date:
    Friday, October 4, 2013 3:12:26 PM EDT

    *** System properties:
    OS=WindowsVista
    OS version=6.1.0
    OS arch=amd64
    Profile arch=x86_64
    Window system=win32
    Java version=1.6.0_13
    Workspace=file:/C:/Users/abc/Workspaces/MyEclipse for Spring 10/
    VM Args=-Xmx512m
    -XX:MaxPermSize=256m
    -XX:ReservedCodeCacheSize=64m
    -Dosgi.nls.warnings=ignore
    -jar
    C:\Users\abc\AppData\Local\MYECLI~1\MYECLI~1\../Common/plugins/ORB7B5~1.JAR

    *** Subscription information
    Product Id: E3MS (MyEclipse for Spring Subscription)
    License version: 3.0
    Full Maintenance Included
    Subscription expiration date (YYYYMMDD): 20131026
    Number of users: 3

    *** Eclipse details:
    MyEclipse for Spring

    Version: 10.6.0

    Build ID: 10.6.0-20120831

    Blueprint: MyEclipse for Spring 10

    Eclipse startup command=-os
    win32
    -ws
    win32
    -arch
    x86_64
    -showsplash
    -launcher
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\myeclipseforspring.exe
    -name
    Myeclipseforspring
    –launcher.library
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\../Common/plugins/org.eclipse.equinox.launcher.i18n.win32.win32.x86_64_4.2.0.v201201111650\eclipse_4201.dll
    -startup
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\../Common/plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
    -exitdata
    2fc4_148
    -install
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10
    -configuration
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\configuration
    -vm
    C:\Users\abc\AppData\Local\MyEclipse for Spring\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\bin\javaw.exe
    —————————————————————————————————————–
    2. We are using Oracle 12g

    3. Hi Pradeep

    Thank you very much for quick response. Here are the requested details.

    1. Installation details
    ———————————————————–
    *** Date:
    Friday, October 4, 2013 3:12:26 PM EDT

    *** System properties:
    OS=WindowsVista
    OS version=6.1.0
    OS arch=amd64
    Profile arch=x86_64
    Window system=win32
    Java version=1.6.0_13
    Workspace=file:/C:/Users/abc/Workspaces/MyEclipse for Spring 10/
    VM Args=-Xmx512m
    -XX:MaxPermSize=256m
    -XX:ReservedCodeCacheSize=64m
    -Dosgi.nls.warnings=ignore
    -jar
    C:\Users\abc\AppData\Local\MYECLI~1\MYECLI~1\../Common/plugins/ORB7B5~1.JAR

    *** Subscription information
    Product Id: E3MS (MyEclipse for Spring Subscription)
    License version: 3.0
    Full Maintenance Included
    Subscription expiration date (YYYYMMDD): 20131026
    Number of users: 3

    *** Eclipse details:
    MyEclipse for Spring

    Version: 10.6.0

    Build ID: 10.6.0-20120831

    Blueprint: MyEclipse for Spring 10

    Eclipse startup command=-os
    win32
    -ws
    win32
    -arch
    x86_64
    -showsplash
    -launcher
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\myeclipseforspring.exe
    -name
    Myeclipseforspring
    –launcher.library
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\../Common/plugins/org.eclipse.equinox.launcher.i18n.win32.win32.x86_64_4.2.0.v201201111650\eclipse_4201.dll
    -startup
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\../Common/plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
    -exitdata
    2fc4_148
    -install
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10
    -configuration
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\configuration
    -vm
    C:\Users\abc\AppData\Local\MyEclipse for Spring\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\bin\javaw.exe
    —————————————————————————————————————–
    2. We are using Oracle 11g

    3. Table Schema
    ——————–
    CREATE TABLE EMPLOYEE
    (
    EMPLOYEEKEY NUMBER(38, 0) NOT NULL,
    EMPLOYEEID VARCHAR2(32 BYTE) NOT NULL,
    FIRSTNAME VARCHAR2(256 BYTE),
    MIDDLENAME VARCHAR2(256 BYTE),
    LASTNAME VARCHAR2(256 BYTE),
    CREATEDBY NUMBER(38, 0),
    LASTMODIFIEDBY NUMBER(38, 0),
    CREATEDDATE TIMESTAMP(6),
    LASTMODIFIEDDATE TIMESTAMP(6),
    SOFTDELETEINDICATOR NUMBER(1, 0) DEFAULT 0 NOT NULL,
    SOURCEOFDATA VARCHAR2(32 BYTE) DEFAULT ‘Application’ NOT NULL
    , CONSTRAINT EMPLOYEE_PK PRIMARY KEY
    (
    EMPLOYEEKEY
    )
    ENABLE
    )
    ;

    ALTER TABLE EMPLOYEE
    ADD CONSTRAINT C_OPERATOR_OPER286 FOREIGN KEY
    (
    CREATEDBY
    )
    REFERENCES EMPLOYEE
    (
    EMPLOYEEKEY
    ) ENABLE
    ;

    ALTER TABLE EMPLOYEE
    ADD CONSTRAINT C_OPERATOR_OPER253 FOREIGN KEY
    (
    LASTMODIFIEDBY
    )
    REFERENCES EMPLOYEE
    (
    EMPLOYEEKEY
    ) ENABLE
    ;

    CREATE UNIQUE INDEX EMPLOYEE_NK ON EMPLOYEE (EMPLOYEEID ASC);
    —————————————————————

    4. Generated code

    /**
    */
    @OneToMany(mappedBy = “employeeByLastmodifiedby”, cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
    @XmlElement(name = “”, namespace = “”)
    private java.util.Set<org.frb.scar.domain.Employee> employeesForCreatedby;
    /**
    */
    @OneToMany(mappedBy = “employeeByLastmodifiedby”, cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
    @XmlElement(name = “”, namespace = “”)
    private java.util.Set<org.frb.scar.domain.Employee> employeesForLastmodifiedby;

    #343041 Reply

    creddy2001
    Member

    Hi Pradeep

    Sorry ignore my previous reply it is copied multiple time.

    Here are the requested details.

    1. Installation details
    ———————————————————–
    *** Date:
    Friday, October 4, 2013 3:12:26 PM EDT

    *** System properties:
    OS=WindowsVista
    OS version=6.1.0
    OS arch=amd64
    Profile arch=x86_64
    Window system=win32
    Java version=1.6.0_13
    Workspace=file:/C:/Users/abc/Workspaces/MyEclipse for Spring 10/
    VM Args=-Xmx512m
    -XX:MaxPermSize=256m
    -XX:ReservedCodeCacheSize=64m
    -Dosgi.nls.warnings=ignore
    -jar
    C:\Users\abc\AppData\Local\MYECLI~1\MYECLI~1\../Common/plugins/ORB7B5~1.JAR

    *** Subscription information
    Product Id: E3MS (MyEclipse for Spring Subscription)
    License version: 3.0
    Full Maintenance Included
    Subscription expiration date (YYYYMMDD): 20131026
    Number of users: 3

    *** Eclipse details:
    MyEclipse for Spring

    Version: 10.6.0

    Build ID: 10.6.0-20120831

    Blueprint: MyEclipse for Spring 10

    Eclipse startup command=-os
    win32
    -ws
    win32
    -arch
    x86_64
    -showsplash
    -launcher
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\myeclipseforspring.exe
    -name
    Myeclipseforspring
    –launcher.library
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\../Common/plugins/org.eclipse.equinox.launcher.i18n.win32.win32.x86_64_4.2.0.v201201111650\eclipse_4201.dll
    -startup
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\../Common/plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
    -exitdata
    2fc4_148
    -install
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10
    -configuration
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\configuration
    -vm
    C:\Users\abc\AppData\Local\MyEclipse for Spring\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\bin\javaw.exe
    —————————————————————————————————————–
    2. We are using Oracle 12g

    3. Hi Pradeep

    Thank you very much for quick response. Here are the requested details.

    1. Installation details
    ———————————————————–
    *** Date:
    Friday, October 4, 2013 3:12:26 PM EDT

    *** System properties:
    OS=WindowsVista
    OS version=6.1.0
    OS arch=amd64
    Profile arch=x86_64
    Window system=win32
    Java version=1.6.0_13
    Workspace=file:/C:/Users/abc/Workspaces/MyEclipse for Spring 10/
    VM Args=-Xmx512m
    -XX:MaxPermSize=256m
    -XX:ReservedCodeCacheSize=64m
    -Dosgi.nls.warnings=ignore
    -jar
    C:\Users\abc\AppData\Local\MYECLI~1\MYECLI~1\../Common/plugins/ORB7B5~1.JAR

    *** Subscription information
    Product Id: E3MS (MyEclipse for Spring Subscription)
    License version: 3.0
    Full Maintenance Included
    Subscription expiration date (YYYYMMDD): 20131026
    Number of users: 3

    *** Eclipse details:
    MyEclipse for Spring

    Version: 10.6.0

    Build ID: 10.6.0-20120831

    Blueprint: MyEclipse for Spring 10

    Eclipse startup command=-os
    win32
    -ws
    win32
    -arch
    x86_64
    -showsplash
    -launcher
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\myeclipseforspring.exe
    -name
    Myeclipseforspring
    –launcher.library
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\../Common/plugins/org.eclipse.equinox.launcher.i18n.win32.win32.x86_64_4.2.0.v201201111650\eclipse_4201.dll
    -startup
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\../Common/plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
    -exitdata
    2fc4_148
    -install
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10
    -configuration
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\configuration
    -vm
    C:\Users\abc\AppData\Local\MyEclipse for Spring\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\bin\javaw.exe
    —————————————————————————————————————–
    2. We are using Oracle 11g

    3. Table Schema
    ——————–
    CREATE TABLE EMPLOYEE
    (
    EMPLOYEEKEY NUMBER(38, 0) NOT NULL,
    EMPLOYEEID VARCHAR2(32 BYTE) NOT NULL,
    FIRSTNAME VARCHAR2(256 BYTE),
    MIDDLENAME VARCHAR2(256 BYTE),
    LASTNAME VARCHAR2(256 BYTE),
    CREATEDBY NUMBER(38, 0),
    LASTMODIFIEDBY NUMBER(38, 0),
    CREATEDDATE TIMESTAMP(6),
    LASTMODIFIEDDATE TIMESTAMP(6),
    SOFTDELETEINDICATOR NUMBER(1, 0) DEFAULT 0 NOT NULL,
    SOURCEOFDATA VARCHAR2(32 BYTE) DEFAULT ‘Application’ NOT NULL
    , CONSTRAINT EMPLOYEE_PK PRIMARY KEY
    (
    EMPLOYEEKEY
    )
    ENABLE
    )
    ;

    ALTER TABLE EMPLOYEE
    ADD CONSTRAINT C_OPERATOR_OPER286 FOREIGN KEY
    (
    CREATEDBY
    )
    REFERENCES EMPLOYEE
    (
    EMPLOYEEKEY
    ) ENABLE
    ;

    ALTER TABLE EMPLOYEE
    ADD CONSTRAINT C_OPERATOR_OPER253 FOREIGN KEY
    (
    LASTMODIFIEDBY
    )
    REFERENCES EMPLOYEE
    (
    EMPLOYEEKEY
    ) ENABLE
    ;

    CREATE UNIQUE INDEX EMPLOYEE_NK ON EMPLOYEE (EMPLOYEEID ASC);

    #343042 Reply

    creddy2001
    Member

    Hi Pradeep

    Sorry once again it copied multiple times. I wont do mistake again.

    Here are the requested details.

    1. Installation details
    ———————————————————–
    *** Date:
    Friday, October 4, 2013 3:12:26 PM EDT

    *** System properties:
    OS=WindowsVista
    OS version=6.1.0
    OS arch=amd64
    Profile arch=x86_64
    Window system=win32
    Java version=1.6.0_13
    Workspace=file:/C:/Users/abc/Workspaces/MyEclipse for Spring 10/
    VM Args=-Xmx512m
    -XX:MaxPermSize=256m
    -XX:ReservedCodeCacheSize=64m
    -Dosgi.nls.warnings=ignore
    -jar
    C:\Users\abc\AppData\Local\MYECLI~1\MYECLI~1\../Common/plugins/ORB7B5~1.JAR

    *** Subscription information
    Product Id: E3MS (MyEclipse for Spring Subscription)
    License version: 3.0
    Full Maintenance Included
    Subscription expiration date (YYYYMMDD): 20131026
    Number of users: 3

    *** Eclipse details:
    MyEclipse for Spring

    Version: 10.6.0

    Build ID: 10.6.0-20120831

    Blueprint: MyEclipse for Spring 10

    Eclipse startup command=-os
    win32
    -ws
    win32
    -arch
    x86_64
    -showsplash
    -launcher
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\myeclipseforspring.exe
    -name
    Myeclipseforspring
    –launcher.library
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\../Common/plugins/org.eclipse.equinox.launcher.i18n.win32.win32.x86_64_4.2.0.v201201111650\eclipse_4201.dll
    -startup
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\../Common/plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
    -exitdata
    2fc4_148
    -install
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10
    -configuration
    C:\Users\abc\AppData\Local\MyEclipse for Spring\MyEclipse for Spring 10\configuration
    -vm
    C:\Users\abc\AppData\Local\MyEclipse for Spring\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\bin\javaw.exe
    —————————————————————————————————————–
    2. We are using Oracle 11g

    3. Table Schema
    ——————–
    CREATE TABLE EMPLOYEE
    (
    EMPLOYEEKEY NUMBER(38, 0) NOT NULL,
    EMPLOYEEID VARCHAR2(32 BYTE) NOT NULL,
    FIRSTNAME VARCHAR2(256 BYTE),
    MIDDLENAME VARCHAR2(256 BYTE),
    LASTNAME VARCHAR2(256 BYTE),
    CREATEDBY NUMBER(38, 0),
    LASTMODIFIEDBY NUMBER(38, 0),
    CREATEDDATE TIMESTAMP(6),
    LASTMODIFIEDDATE TIMESTAMP(6),
    SOFTDELETEINDICATOR NUMBER(1, 0) DEFAULT 0 NOT NULL,
    SOURCEOFDATA VARCHAR2(32 BYTE) DEFAULT ‘Application’ NOT NULL
    , CONSTRAINT EMPLOYEE_PK PRIMARY KEY
    (
    EMPLOYEEKEY
    )
    ENABLE
    )
    ;

    ALTER TABLE EMPLOYEE
    ADD CONSTRAINT C_OPERATOR_OPER286 FOREIGN KEY
    (
    CREATEDBY
    )
    REFERENCES EMPLOYEE
    (
    EMPLOYEEKEY
    ) ENABLE
    ;

    ALTER TABLE EMPLOYEE
    ADD CONSTRAINT C_OPERATOR_OPER253 FOREIGN KEY
    (
    LASTMODIFIEDBY
    )
    REFERENCES EMPLOYEE
    (
    EMPLOYEEKEY
    ) ENABLE
    ;

    CREATE UNIQUE INDEX EMPLOYEE_NK ON EMPLOYEE (EMPLOYEEID ASC);

    ——————————————————————————————————————-

    4. Generted code

    /**
    */
    @OneToMany(mappedBy = “employeeByLastmodifiedby”, cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
    @XmlElement(name = “”, namespace = “”)
    private java.util.Set<org.frb.scar.domain.Employee> employeesForCreatedby;
    /**
    */
    @OneToMany(mappedBy = “employeeByLastmodifiedby”, cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
    @XmlElement(name = “”, namespace = “”)
    private java.util.Set<org.frb.scar.domain.Employee> employeesForLastmodifiedby;

    #343114 Reply

    support-tony
    Keymaster

    creddy2001,

    Sorry for the delay in responding, we have had some power issues.

    Thanks for the information. We’ve managed to replicate the problem and have raised a bug report for the developers to investigate.

    It seems to be a problem with multiple associations to the same table (in your case, it’s the same table at both ends of the association but that is not the problem). The only workaround we have so far is to manually alter the mappedBy parameter. It will not be overwritten if you re-scaffold the application. So, in your case, the modified field becomes:

    
    @OneToMany(mappedBy = "employeeByLastcreatedby", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
    @XmlElement(name = "", namespace = "")
    private java.util.Set<org.frb.scar.domain.Employee> employeesForCreatedby; 
    

    Sorry for the inconvenience. This topic will be updated when there is a fix for the bug.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Incorrect mappedBy relation in entities – urgent

You must be logged in to post in the forum log in