openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leo Tu (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (OPENJPA-1605) ReverseMappingTool (SchemaGenerator) bug
Date Tue, 06 Apr 2010 14:06:33 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-1605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12853978#action_12853978
] 

Leo Tu edited comment on OPENJPA-1605 at 4/6/10 2:05 PM:
---------------------------------------------------------

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() {
    }
...
}


      was (Author: leo.tu):
    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>
  
> ReverseMappingTool (SchemaGenerator) bug
> ----------------------------------------
>
>                 Key: OPENJPA-1605
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1605
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta3
>            Reporter: Leo Tu
>
> 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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message