OpenJPA
  1. OpenJPA
  2. OPENJPA-1605

ReverseMappingTool (SchemaGenerator) bug

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-beta3
    • Fix Version/s: 2.0.0
    • Component/s: None
    • Labels:
      None

      Description

      org.apache.openjpa.jdbc.schema.SchemaGenerator.java
      =============================================
      ...
      ...
      public void generateTables(DBIdentifier schemaName, DBIdentifier tableName,
      Connection conn, DatabaseMetaData meta) {
      ...
      Table table;
      DBIdentifier tableSchema = DBIdentifier.NULL;
      for (int i = 0; cols != null && i < cols.length; i++) {
      if (DBIdentifier.isNull(tableName) || tableName.equals("%"))

      { <--- bug code line tableName = cols[i].getTableIdentifier(); <--- bug code line }

      ...
      ...
      }
      }

      if parameter tableName is null, than tableName is always been set the first column table Identifier
      --> "cols[0].getTableIdentifier() "
      this cause only generate first table class file with wrong columns.

        Issue Links

          Activity

          Hide
          Rick Curtis added a comment -

          If possible, please post a unit test exhibiting the bug that you've pointed out.

          Show
          Rick Curtis added a comment - If possible, please post a unit test exhibiting the bug that you've pointed out.
          Hide
          Leo Tu added a comment - - edited

          Hi Rick Curtis, bellow is my unit test:

          (1) Create Table for Testing:
          ==============================================
          CREATE DATABASE `abc`;

          DROP TABLE IF EXISTS `abc`.`mycompany`;
          CREATE TABLE `abc`.`mycompany` (
          `COMPANY_ID` varchar(20) NOT NULL,
          `ENGNAME` varchar(100) default NULL,
          `COUNTRY` varchar(5) default NULL,
          `CITY` varchar(20) default NULL,
          `ZIP` varchar(10) default NULL,
          `PHONE` varchar(40) default NULL,
          PRIMARY KEY (`COMPANY_ID`)
          ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

          DROP TABLE IF EXISTS `abc`.`mycompany_emp`;
          CREATE TABLE `abc`.`mycompany_emp` (
          `COMPANY_ID` varchar(20) NOT NULL,
          `EMPNAME` varchar(50) NOT NULL default '',
          `ROLE` varchar(30) default NULL,
          `EMAIL` varchar(100) default NULL,
          `ERP_ID` varchar(10) default NULL,
          PRIMARY KEY (`COMPANY_ID`,`EMPNAME`),
          CONSTRAINT `COMPANY_EMP_FK1` FOREIGN KEY (`COMPANY_ID`) REFERENCES `mycompany` (`COMPANY_ID`)
          ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

          DROP TABLE IF EXISTS `abc`.`myrole`;
          CREATE TABLE `abc`.`myrole` (
          `ROLE_ID` varchar(30) NOT NULL,
          `USER_ID` varchar(30) NOT NULL default '',
          `IS_ENABLE` varchar(1) default NULL,
          `LOCATION` varchar(30) default NULL,
          PRIMARY KEY (`ROLE_ID`,`USER_ID`)
          ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

          (2) ANT build.xml for Testing:
          ==============================================
          <?xml version="1.0" encoding="UTF-8"?>
          <project name="test" default="reverse-schema-test">

          <property name="jdbc.driver" value="com.mysql.jdbc.Driver" />
          <property name="jdbc.url" value="jdbc:mysql://localhost:3306/abc" />
          <property name="jdbc.username" value="test" />
          <property name="jdbc.password" value="test123" />
          <property name="jdbc.package" value="db.model.test" />

          <property name="project.path" value="$

          {basedir}" />
          <property name="webapp.path" location="${project.path}/WebContent" />
          <property name="java.classes.output.path" location="${webapp.path}/WEB-INF/classes" />
          <property name="java.code.src_auto_gen_test" value="${project.path}/src_auto_gen_test" />

          <!-- echo -->
          <echo>ant.version=[${ant.version}]</echo>
          <echo>ant.java.version=[${ant.java.version}]</echo>
          <echo>java.home=[${java.home}]</echo>
          <!--
          <echo>basedir=[${basedir}

          ]</echo>
          <echo>project.path=[$

          {project.path}]</echo>
          <echo>webapp.path=[${webapp.path}]</echo>
          <echo>java.classes.output.path=[${java.classes.output.path}]</echo>
          -->

          <!-- classpath -->
          <path id="default.classpath">

          <!-- for openjpa-1.2.2 -->
          <!--
          <fileset dir="D:/download/apache-java/OpenJPA/apache-openjpa-1.2.2-binary/apache-openjpa-1.2.2">
          <include name="openjpa-1.2.2.jar" />
          <include name="lib/*.jar" />
          </fileset>
          -->

          <!-- for openjpa-2.0.0-beta3 -->
          <fileset dir="D:/download/apache-java/OpenJPA/apache-openjpa-2.0.0-beta3-binary/apache-openjpa-2.0.0-beta3">
          <include name="openjpa-2.0.0-beta3.jar" />
          <include name="lib/*.jar" />
          </fileset>

          <!-- for jdbc -->
          <fileset dir="D:/download/MS-SQL/mysql-connector-java-5.1.12">
          <include name="mysql-connector-java-5.1.12-bin.jar" />
          </fileset>

          <pathelement location="${java.classes.output.path}" />
          </path>

          <taskdef name="reversemappingtool" classname="org.apache.openjpa.jdbc.ant.ReverseMappingToolTask">
          <classpath refid="default.classpath" />
          </taskdef>

          <target name="reverse-schema-test" depends="" description="Generate java files from the database schema">
          <delete dir="${java.code.src_auto_gen_test}" />
          <mkdir dir="${java.code.src_auto_gen_test}" />
          <delete file="${project.path}

          /orm.xml" />

          <reversemappingtool inverseRelations="true" package="$

          {jdbc.package}

          " directory="$

          {java.code.src_auto_gen_test}

          " innerIdentityClasses="true" useBuiltinIdentityClass="false" identityClassSuffix="Pk" nullableAsObject="true" generateAnnotations="true" useSchemaName="false" detachable="true" useGenericCollections="true">
          <config connectiondrivername="$

          {jdbc.driver}

          " connectionurl="$

          {jdbc.url}

          " connectionusername="$

          {jdbc.username}

          " connectionpassword="$

          {jdbc.password}

          " />
          <codeformat tabSpaces="4" spaceBeforeParen="false" braceOnSameLine="true" />
          </reversemappingtool>
          </target>

          </project>

          (3) ANT build log message for version: "openjpa-1.2.2"
          (<path id="default.classpath">
          ...
          <include name="openjpa-1.2.2.jar" />
          ...
          </path>)

          ==============================================
          Buildfile: D:\developer\workspace-soho\magic-web\build_test.xml
          [echo] ant.version=[Apache Ant version 1.7.1 compiled on June 27 2008]
          [echo] ant.java.version=[1.6]
          [echo] java.home=[C:\Program Files\Java\jre6]
          reverse-schema-test:
          [mkdir] Created dir: D:\developer\workspace-soho\magic-web\src_auto_gen_test
          [delete] Deleting: D:\developer\workspace-soho\magic-web\orm.xml
          [reversemappingtool] 62 server-pu INFO [main] openjpa.Tool - The reverse mapping tool will run on the database. The tool is gathering schema information; this process may take some time. Enable the org.apache.openjpa.jdbc.Schema logging category to see messages about schema data.
          [reversemappingtool] 125 server-pu INFO [main] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.MySQLDictionary".
          [reversemappingtool] 984 server-pu INFO [main] openjpa.Tool - ReverseMappingTool : generating classes.
          [reversemappingtool] 1328 server-pu INFO [main] openjpa.Tool - Generating annotations.
          [reversemappingtool] 1359 server-pu INFO [main] openjpa.MetaData - Writing class "db.model.test.Mycompany".
          [reversemappingtool] 1375 server-pu INFO [main] openjpa.MetaData - Writing class "db.model.test.MycompanyEmp".
          [reversemappingtool] 1375 server-pu INFO [main] openjpa.MetaData - Writing class "db.model.test.Myrole".
          [reversemappingtool] 1390 server-pu INFO [main] openjpa.Tool - Writing generated class source code.
          [reversemappingtool] 1390 server-pu INFO [main] openjpa.MetaData - Writing java code for generated type "db.model.test.Mycompany".
          [reversemappingtool] 1406 server-pu INFO [main] openjpa.Enhance - Generating an application id for type "class db.model.test.Mycompany".
          [reversemappingtool] 1453 server-pu INFO [main] openjpa.MetaData - Writing java code for generated type "db.model.test.MycompanyEmp".
          [reversemappingtool] 1453 server-pu INFO [main] openjpa.Enhance - Generating an application id for type "class db.model.test.MycompanyEmp".
          [reversemappingtool] 1453 server-pu INFO [main] openjpa.MetaData - Writing java code for generated type "db.model.test.Myrole".
          [reversemappingtool] 1453 server-pu INFO [main] openjpa.Enhance - Generating an application id for type "class db.model.test.Myrole".
          [reversemappingtool] 1468 server-pu INFO [main] openjpa.Tool - Writing generated metadata.
          [reversemappingtool] 1500 server-pu INFO [main] openjpa.MetaData - Writing to file "orm.xml".
          [reversemappingtool] 1515 server-pu INFO [main] openjpa.MetaData - Writing class "db.model.test.Mycompany".
          [reversemappingtool] 1531 server-pu INFO [main] openjpa.MetaData - Writing class "db.model.test.MycompanyEmp".
          [reversemappingtool] 1531 server-pu INFO [main] openjpa.MetaData - Writing class "db.model.test.Myrole".
          BUILD SUCCESSFUL
          Total time: 2 seconds

          (4) ANT build log message for version: "openjpa-2.0.0-beta3"
          (<path id="default.classpath">
          ...
          <include name="openjpa-2.0.0-beta3.jar" />
          ...
          </path>)
          ==============================================
          Buildfile: D:\developer\workspace-soho\magic-web\build_test.xml
          [echo] ant.version=[Apache Ant version 1.7.1 compiled on June 27 2008]
          [echo] ant.java.version=[1.6]
          [echo] java.home=[C:\Program Files\Java\jre6]
          reverse-schema-test:
          [mkdir] Created dir: D:\developer\workspace-soho\magic-web\src_auto_gen_test
          [delete] Deleting: D:\developer\workspace-soho\magic-web\orm.xml
          [reversemappingtool] 93 server-pu INFO [main] openjpa.Tool - The reverse mapping tool will run on the database. The tool is gathering schema information; this process may take some time. Enable the org.apache.openjpa.jdbc.Schema logging category to see messages about schema data.
          [reversemappingtool] 406 server-pu INFO [main] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.MySQLDictionary".
          [reversemappingtool] 1343 server-pu INFO [main] openjpa.Tool - ReverseMappingTool : generating classes.
          [reversemappingtool] 1640 server-pu INFO [main] openjpa.Tool - Generating annotations.
          [reversemappingtool] 1656 server-pu INFO [main] openjpa.MetaData - Writing class "db.model.test.Mycompany".
          [reversemappingtool] 1687 server-pu INFO [main] openjpa.Tool - Writing generated class source code.
          [reversemappingtool] 1687 server-pu INFO [main] openjpa.MetaData - Writing java code for generated type "db.model.test.Mycompany".
          [reversemappingtool] 1718 server-pu INFO [main] openjpa.Enhance - Generating an application id for type "class db.model.test.Mycompany".
          [reversemappingtool] 1765 server-pu INFO [main] openjpa.Tool - Writing generated metadata.
          [reversemappingtool] 1796 server-pu INFO [main] openjpa.MetaData - Writing to file "orm.xml".
          [reversemappingtool] 1828 server-pu INFO [main] openjpa.MetaData - Writing class "db.model.test.Mycompany".
          BUILD SUCCESSFUL
          Total time: 3 seconds

          (5) /META-INF/persistence.xml
          ==============================================
          <?xml version="1.0" encoding="UTF-8" ?>
          <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
          http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
          version="1.0">

          <persistence-unit name="server-pu" transaction-type="RESOURCE_LOCAL">
          <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
          <properties>
          <property name="openjpa.jdbc.DBDictionary" value="storeCharsAsNumbers=false" />
          <property name="openjpa.jdbc.SynchronizeMappings" value="false" />
          <property name="openjpa.Log" value="SQL=TRACE"></property>
          <property name="openjpa.ConnectionFactoryProperties" value="PrettyPrint=true,PrettyPrintLineLength=72"></property>
          </properties>

          </persistence-unit>
          </persistence>

          **********************************************
          (6) Result
          ==> version: "openjpa-1.2.2" is correct, generate three java class files.
          i.e, "Mycompany "

          @Entity
          @Table(name="mycompany")
          @IdClass(db.model.test.Mycompany.Pk.class)
          public class Mycompany {
          @Basic
          @Column(length=20)
          private String city;

          @Id
          @Column(name="COMPANY_ID", length=20)
          private String companyId;

          @Basic
          @Column(length=5)
          private String country;

          @Basic
          @Column(length=100)
          private String engname;

          @OneToMany(targetEntity=db.model.test.MycompanyEmp.class, mappedBy="mycompany", cascade=CascadeType.MERGE)
          private Set<MycompanyEmp> mycompanyEmps = new HashSet<MycompanyEmp>();

          @Basic
          @Column(length=40)
          private String phone;

          @Basic
          @Column(length=10)
          private String zip;

          public Mycompany() {
          }
          ...
          }

          ==> version: "openjpa-2.0.0-beta3" is incorrect, generate only one file:
          i.e, "Mycompany " with wrong columns

          /**

          • Auto-generated by:
          • org.apache.openjpa.jdbc.meta.ReverseMappingTool$AnnotatedCodeGenerator
            */
            @Entity
            @Table(name="mycompany")
            @IdClass(db.model.test.Mycompany.Pk.class)
            public class Mycompany {
            @Basic
            @Column(length=20)
            private String city;

          @Id
          @Column(name="COMPANY_ID", length=20)
          private String companyId;

          @Basic
          @Column(length=5)
          private String country;

          @Basic
          @Column(length=100)
          private String email;

          @Basic
          @Column(nullable=false, length=50)
          private String empname;

          @Basic
          @Column(length=100)
          private String engname;

          @Basic
          @Column(name="ERP_ID", length=10)
          private String erpId;

          @Basic
          @Column(name="IS_ENABLE", length=1)
          private String isEnable;

          @Basic
          @Column(length=30)
          private String location;

          @Basic
          @Column(length=40)
          private String phone;

          @Basic
          @Column(length=30)
          private String role;

          @Basic
          @Column(name="ROLE_ID", nullable=false, length=30)
          private String roleId;

          @Basic
          @Column(name="USER_ID", nullable=false, length=30)
          private String userId;

          @Basic
          @Column(length=10)
          private String zip;

          public Mycompany() {
          }
          ...
          }

          Show
          Leo Tu added a comment - - edited Hi Rick Curtis, bellow is my unit test: (1) Create Table for Testing: ============================================== CREATE DATABASE `abc`; DROP TABLE IF EXISTS `abc`.`mycompany`; CREATE TABLE `abc`.`mycompany` ( `COMPANY_ID` varchar(20) NOT NULL, `ENGNAME` varchar(100) default NULL, `COUNTRY` varchar(5) default NULL, `CITY` varchar(20) default NULL, `ZIP` varchar(10) default NULL, `PHONE` varchar(40) default NULL, PRIMARY KEY (`COMPANY_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `abc`.`mycompany_emp`; CREATE TABLE `abc`.`mycompany_emp` ( `COMPANY_ID` varchar(20) NOT NULL, `EMPNAME` varchar(50) NOT NULL default '', `ROLE` varchar(30) default NULL, `EMAIL` varchar(100) default NULL, `ERP_ID` varchar(10) default NULL, PRIMARY KEY (`COMPANY_ID`,`EMPNAME`), CONSTRAINT `COMPANY_EMP_FK1` FOREIGN KEY (`COMPANY_ID`) REFERENCES `mycompany` (`COMPANY_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `abc`.`myrole`; CREATE TABLE `abc`.`myrole` ( `ROLE_ID` varchar(30) NOT NULL, `USER_ID` varchar(30) NOT NULL default '', `IS_ENABLE` varchar(1) default NULL, `LOCATION` varchar(30) default NULL, PRIMARY KEY (`ROLE_ID`,`USER_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; (2) ANT build.xml for Testing: ============================================== <?xml version="1.0" encoding="UTF-8"?> <project name="test" default="reverse-schema-test"> <property name="jdbc.driver" value="com.mysql.jdbc.Driver" /> <property name="jdbc.url" value="jdbc:mysql://localhost:3306/abc" /> <property name="jdbc.username" value="test" /> <property name="jdbc.password" value="test123" /> <property name="jdbc.package" value="db.model.test" /> <property name="project.path" value="$ {basedir}" /> <property name="webapp.path" location="${project.path}/WebContent" /> <property name="java.classes.output.path" location="${webapp.path}/WEB-INF/classes" /> <property name="java.code.src_auto_gen_test" value="${project.path}/src_auto_gen_test" /> <!-- echo --> <echo>ant.version= [${ant.version}] </echo> <echo>ant.java.version= [${ant.java.version}] </echo> <echo>java.home= [${java.home}] </echo> <!-- <echo>basedir=[${basedir} ]</echo> <echo>project.path=[$ {project.path}]</echo> <echo>webapp.path= [${webapp.path}] </echo> <echo>java.classes.output.path=[${java.classes.output.path}]</echo> --> <!-- classpath --> <path id="default.classpath"> <!-- for openjpa-1.2.2 --> <!-- <fileset dir="D:/download/apache-java/OpenJPA/apache-openjpa-1.2.2-binary/apache-openjpa-1.2.2"> <include name="openjpa-1.2.2.jar" /> <include name="lib/*.jar" /> </fileset> --> <!-- for openjpa-2.0.0-beta3 --> <fileset dir="D:/download/apache-java/OpenJPA/apache-openjpa-2.0.0-beta3-binary/apache-openjpa-2.0.0-beta3"> <include name="openjpa-2.0.0-beta3.jar" /> <include name="lib/*.jar" /> </fileset> <!-- for jdbc --> <fileset dir="D:/download/MS-SQL/mysql-connector-java-5.1.12"> <include name="mysql-connector-java-5.1.12-bin.jar" /> </fileset> <pathelement location="${java.classes.output.path}" /> </path> <taskdef name="reversemappingtool" classname="org.apache.openjpa.jdbc.ant.ReverseMappingToolTask"> <classpath refid="default.classpath" /> </taskdef> <target name="reverse-schema-test" depends="" description="Generate java files from the database schema"> <delete dir="${java.code.src_auto_gen_test}" /> <mkdir dir="${java.code.src_auto_gen_test}" /> <delete file="${project.path} /orm.xml" /> <reversemappingtool inverseRelations="true" package="$ {jdbc.package} " directory="$ {java.code.src_auto_gen_test} " innerIdentityClasses="true" useBuiltinIdentityClass="false" identityClassSuffix="Pk" nullableAsObject="true" generateAnnotations="true" useSchemaName="false" detachable="true" useGenericCollections="true"> <config connectiondrivername="$ {jdbc.driver} " connectionurl="$ {jdbc.url} " connectionusername="$ {jdbc.username} " connectionpassword="$ {jdbc.password} " /> <codeformat tabSpaces="4" spaceBeforeParen="false" braceOnSameLine="true" /> </reversemappingtool> </target> </project> (3) ANT build log message for version: "openjpa-1.2.2" (<path id="default.classpath"> ... <include name="openjpa-1.2.2.jar" /> ... </path>) ============================================== Buildfile: D:\developer\workspace-soho\magic-web\build_test.xml [echo] ant.version= [Apache Ant version 1.7.1 compiled on June 27 2008] [echo] ant.java.version= [1.6] [echo] java.home= [C:\Program Files\Java\jre6] reverse-schema-test: [mkdir] Created dir: D:\developer\workspace-soho\magic-web\src_auto_gen_test [delete] Deleting: D:\developer\workspace-soho\magic-web\orm.xml [reversemappingtool] 62 server-pu INFO [main] openjpa.Tool - The reverse mapping tool will run on the database. The tool is gathering schema information; this process may take some time. Enable the org.apache.openjpa.jdbc.Schema logging category to see messages about schema data. [reversemappingtool] 125 server-pu INFO [main] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.MySQLDictionary". [reversemappingtool] 984 server-pu INFO [main] openjpa.Tool - ReverseMappingTool : generating classes. [reversemappingtool] 1328 server-pu INFO [main] openjpa.Tool - Generating annotations. [reversemappingtool] 1359 server-pu INFO [main] openjpa.MetaData - Writing class "db.model.test.Mycompany". [reversemappingtool] 1375 server-pu INFO [main] openjpa.MetaData - Writing class "db.model.test.MycompanyEmp". [reversemappingtool] 1375 server-pu INFO [main] openjpa.MetaData - Writing class "db.model.test.Myrole". [reversemappingtool] 1390 server-pu INFO [main] openjpa.Tool - Writing generated class source code. [reversemappingtool] 1390 server-pu INFO [main] openjpa.MetaData - Writing java code for generated type "db.model.test.Mycompany". [reversemappingtool] 1406 server-pu INFO [main] openjpa.Enhance - Generating an application id for type "class db.model.test.Mycompany". [reversemappingtool] 1453 server-pu INFO [main] openjpa.MetaData - Writing java code for generated type "db.model.test.MycompanyEmp". [reversemappingtool] 1453 server-pu INFO [main] openjpa.Enhance - Generating an application id for type "class db.model.test.MycompanyEmp". [reversemappingtool] 1453 server-pu INFO [main] openjpa.MetaData - Writing java code for generated type "db.model.test.Myrole". [reversemappingtool] 1453 server-pu INFO [main] openjpa.Enhance - Generating an application id for type "class db.model.test.Myrole". [reversemappingtool] 1468 server-pu INFO [main] openjpa.Tool - Writing generated metadata. [reversemappingtool] 1500 server-pu INFO [main] openjpa.MetaData - Writing to file "orm.xml". [reversemappingtool] 1515 server-pu INFO [main] openjpa.MetaData - Writing class "db.model.test.Mycompany". [reversemappingtool] 1531 server-pu INFO [main] openjpa.MetaData - Writing class "db.model.test.MycompanyEmp". [reversemappingtool] 1531 server-pu INFO [main] openjpa.MetaData - Writing class "db.model.test.Myrole". BUILD SUCCESSFUL Total time: 2 seconds (4) ANT build log message for version: "openjpa-2.0.0-beta3" (<path id="default.classpath"> ... <include name="openjpa-2.0.0-beta3.jar" /> ... </path>) ============================================== Buildfile: D:\developer\workspace-soho\magic-web\build_test.xml [echo] ant.version= [Apache Ant version 1.7.1 compiled on June 27 2008] [echo] ant.java.version= [1.6] [echo] java.home= [C:\Program Files\Java\jre6] reverse-schema-test: [mkdir] Created dir: D:\developer\workspace-soho\magic-web\src_auto_gen_test [delete] Deleting: D:\developer\workspace-soho\magic-web\orm.xml [reversemappingtool] 93 server-pu INFO [main] openjpa.Tool - The reverse mapping tool will run on the database. The tool is gathering schema information; this process may take some time. Enable the org.apache.openjpa.jdbc.Schema logging category to see messages about schema data. [reversemappingtool] 406 server-pu INFO [main] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.MySQLDictionary". [reversemappingtool] 1343 server-pu INFO [main] openjpa.Tool - ReverseMappingTool : generating classes. [reversemappingtool] 1640 server-pu INFO [main] openjpa.Tool - Generating annotations. [reversemappingtool] 1656 server-pu INFO [main] openjpa.MetaData - Writing class "db.model.test.Mycompany". [reversemappingtool] 1687 server-pu INFO [main] openjpa.Tool - Writing generated class source code. [reversemappingtool] 1687 server-pu INFO [main] openjpa.MetaData - Writing java code for generated type "db.model.test.Mycompany". [reversemappingtool] 1718 server-pu INFO [main] openjpa.Enhance - Generating an application id for type "class db.model.test.Mycompany". [reversemappingtool] 1765 server-pu INFO [main] openjpa.Tool - Writing generated metadata. [reversemappingtool] 1796 server-pu INFO [main] openjpa.MetaData - Writing to file "orm.xml". [reversemappingtool] 1828 server-pu INFO [main] openjpa.MetaData - Writing class "db.model.test.Mycompany". BUILD SUCCESSFUL Total time: 3 seconds (5) /META-INF/persistence.xml ============================================== <?xml version="1.0" encoding="UTF-8" ?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd " version="1.0"> <persistence-unit name="server-pu" transaction-type="RESOURCE_LOCAL"> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> <properties> <property name="openjpa.jdbc.DBDictionary" value="storeCharsAsNumbers=false" /> <property name="openjpa.jdbc.SynchronizeMappings" value="false" /> <property name="openjpa.Log" value="SQL=TRACE"></property> <property name="openjpa.ConnectionFactoryProperties" value="PrettyPrint=true,PrettyPrintLineLength=72"></property> </properties> </persistence-unit> </persistence> ********************************************** (6) Result ==> version: "openjpa-1.2.2" is correct, generate three java class files. i.e, "Mycompany " @Entity @Table(name="mycompany") @IdClass(db.model.test.Mycompany.Pk.class) public class Mycompany { @Basic @Column(length=20) private String city; @Id @Column(name="COMPANY_ID", length=20) private String companyId; @Basic @Column(length=5) private String country; @Basic @Column(length=100) private String engname; @OneToMany(targetEntity=db.model.test.MycompanyEmp.class, mappedBy="mycompany", cascade=CascadeType.MERGE) private Set<MycompanyEmp> mycompanyEmps = new HashSet<MycompanyEmp>(); @Basic @Column(length=40) private String phone; @Basic @Column(length=10) private String zip; public Mycompany() { } ... } ==> version: "openjpa-2.0.0-beta3" is incorrect, generate only one file: i.e, "Mycompany " with wrong columns /** Auto-generated by: org.apache.openjpa.jdbc.meta.ReverseMappingTool$AnnotatedCodeGenerator */ @Entity @Table(name="mycompany") @IdClass(db.model.test.Mycompany.Pk.class) public class Mycompany { @Basic @Column(length=20) private String city; @Id @Column(name="COMPANY_ID", length=20) private String companyId; @Basic @Column(length=5) private String country; @Basic @Column(length=100) private String email; @Basic @Column(nullable=false, length=50) private String empname; @Basic @Column(length=100) private String engname; @Basic @Column(name="ERP_ID", length=10) private String erpId; @Basic @Column(name="IS_ENABLE", length=1) private String isEnable; @Basic @Column(length=30) private String location; @Basic @Column(length=40) private String phone; @Basic @Column(length=30) private String role; @Basic @Column(name="ROLE_ID", nullable=false, length=30) private String roleId; @Basic @Column(name="USER_ID", nullable=false, length=30) private String userId; @Basic @Column(length=10) private String zip; public Mycompany() { } ... }
          Hide
          Jeremy Bauer added a comment -

          Fixed in 2.0.x branch and trunk. Leo - Thanks for reporting this problem and for the test case. This problem was breaking one of the reverse mapping example, so it can be verified by running that example.

          Show
          Jeremy Bauer added a comment - Fixed in 2.0.x branch and trunk. Leo - Thanks for reporting this problem and for the test case. This problem was breaking one of the reverse mapping example, so it can be verified by running that example.
          Hide
          Donald Woods added a comment -

          Only need Fix Version of 2.0.0

          Show
          Donald Woods added a comment - Only need Fix Version of 2.0.0

            People

            • Assignee:
              Jeremy Bauer
              Reporter:
              Leo Tu
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development