facebook

Problem with reverse engineering and changing data types

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #268602 Reply

    dkirvan
    Member

    *** Date: Mon Apr 09 16:39:28 EDT 2007

    *** System properties:
    OS=WindowsXP
    OS version=5.1
    Java version=1.5.0_10

    *** MyEclipse details:
    MyEclipse Enterprise Workbench

    Version: 5.0 GA
    Build id: 20060805-5.0-GA

    *** Eclipse details:
    MyEclipse Enterprise Workbench

    Version: 5.0.1 GA
    Build id: 20060810-5.0.1-GA

    Eclipse Graphical Editing Framework

    Version: 3.2.0.v20060626
    Build id: 20060627-0816

    Eclipse Platform

    Version: 3.2.1.r321_v20060921-b_XVA-INSQSyMtx
    Build id: M20060921-0945

    Eclipse RCP

    Version: 3.2.1.r321_v20060801-2ekW2BxmcpPUOoq
    Build id: M20060921-0945

    Eclipse Java Development Tools

    Version: 3.2.1.r321_v20060905-R4CM1Znkvre9wC-
    Build id: M20060921-0945

    Eclipse Plug-in Development Environment

    Version: 3.2.1.r321_v20060823-6vYLLdQ3Nk8DrFG
    Build id: M20060921-0945

    Eclipse Project SDK

    Version: 3.2.1.r321_v20060801-tQ1w49KnTArT0FZ
    Build id: M20060921-0945

    Eclipse startup command=-os
    win32
    -ws
    win32
    -arch
    x86
    -launcher
    C:\Program Files\Eclipse3.2\eclipse\eclipse.exe
    -name
    Eclipse
    -showsplash
    600
    -exitdata
    268_7c
    -product
    com.genuitec.myeclipse.product.ide
    -vm
    C:\WINDOWS\system32\javaw.exe

    THE PROBLEM:
    I am trying to use the hibernate.reveng.xml during the reverse engineering process to set variables to the data type that I want them to be. No matter what I try (inlcuding trying both upper and lower case) the data values are created as long.

    OUTPUT FROM REVERSE ENGINEERING:
    This shows rolTypeAttrId. dataPrecCnt and dataLenCnt as data type long I am trying to make them java.lang.Integer.

    <hibernate-mapping>
    <class name=”com.agristats.emd.persistence.RolTypeAttr” table=”rol_type_attr” schema=”public”>
    <id name=”rolTypeAttrId” type=”long”>
    <column name=”rol_type_attr_id” />
    <generator class=”sequence” />
    </id>
    <property name=”stsCd” type=”string”>
    <column name=”sts_cd” length=”1″ not-null=”true” />
    </property>
    <property name=”lastUpdtTs” type=”timestamp”>
    <column name=”last_updt_ts” length=”29″ />
    </property>
    <property name=”entrTs” type=”timestamp”>
    <column name=”entr_ts” length=”29″ not-null=”true” />
    </property>
    <property name=”nm” type=”string”>
    <column name=”nm” length=”50″ not-null=”true” />
    </property>
    <property name=”dataTypeNm” type=”string”>
    <column name=”data_type_nm” length=”50″ not-null=”true” />
    </property>
    <property name=”dataPrecCnt” type=”long”>
    <column name=”data_prec_cnt” precision=”2″ scale=”0″ not-null=”true” />
    </property>
    <property name=”dataLenCnt” type=”long”>
    <column name=”data_len_cnt” precision=”3″ scale=”0″ not-null=”true” />
    </property>
    <property name=”entrUsrId” type=”string”>
    <column name=”entr_usr_id” length=”20″ not-null=”true” />
    </property>
    <property name=”lastUpdtUsrId” type=”string”>
    <column name=”last_updt_usr_id” length=”20″ />
    </property>
    <set name=”rolAttrVals” inverse=”true”>
    <key>
    <column name=”rol_type_attr_id” not-null=”true” />
    </key>
    <one-to-many class=”com.agristats.emd.persistence.RolAttrVal” />
    </set>
    <set name=”rolTypeAsgnAttrs” inverse=”true”>
    <key>
    <column name=”rol_type_attr_id” not-null=”true” />
    </key>
    <one-to-many class=”com.agristats.emd.persistence.RolTypeAsgnAttr” />
    </set>
    </class>
    </hibernate-mapping>

    HIBERNATE.REVENG.XML Looks like the following:
    <hibernate-reverse-engineering>
    <type-mapping>
    <sql-type jdbc-type=”int8″ hibernate-type=”java.lang.Integer” not-null=”true”/>
    <sql-type jdbc-type=”INT8″ hibernate-type=”java.lang.Integer” not-null=”true”/>
    <sql-type jdbc-type=”int8″ hibernate-type=”java.lang.Integer” not-null=”false”/>
    <sql-type jdbc-type=”INT8″ hibernate-type=”java.lang.Integer” not-null=”false”/>
    <sql-type jdbc-type=”BIGINT” hibernate-type=”java.lang.Integer” not-null=”false”/>
    <sql-type jdbc-type=”bigint” hibernate-type=”java.lang.Integer” not-null=”false”/>
    <sql-type jdbc-type=”BIGINT” hibernate-type=”java.lang.Integer” not-null=”true”/>
    <sql-type jdbc-type=”bigint” hibernate-type=”java.lang.Integer” not-null=”true”/>
    <sql-type jdbc-type=”NUMERIC” hibernate-type=”java.lang.Integer” not-null=”false”/>
    <sql-type jdbc-type=”NUMERIC” hibernate-type=”java.lang.Integer” not-null=”true”/>
    <sql-type jdbc-type=”NUMERIC(2,0)”
    hibernate-type=”java.lang.Integer” not-null=”false”/>
    <sql-type jdbc-type=”NUMERIC(2,0)”
    hibernate-type=”java.lang.Integer” not-null=”true”/>
    <sql-type jdbc-type=”NUMERIC(3,0)”
    hibernate-type=”java.lang.Integer” not-null=”false”/>
    <sql-type jdbc-type=”NUMERIC(3,0)”
    hibernate-type=”java.lang.Integer” not-null=”true”/>
    <sql-type jdbc-type=”numeric” hibernate-type=”java.lang.Integer” not-null=”false”/>
    <sql-type jdbc-type=”numeric” hibernate-type=”java.lang.Integer” not-null=”true”/>
    <sql-type jdbc-type=”numeric(2,0)”
    hibernate-type=”java.lang.Integer” not-null=”false”/>
    <sql-type jdbc-type=”numeric(2,0)”
    hibernate-type=”java.lang.Integer” not-null=”true”/>
    <sql-type jdbc-type=”numeric(3,0)”
    hibernate-type=”java.lang.Integer” not-null=”false”/>
    <sql-type jdbc-type=”numeric(3,0)”
    hibernate-type=”java.lang.Integer” not-null=”true”/>
    <sql-type jdbc-type=”bigint” hibernate-type=”java.lang.Integer” not-null=”true”/>
    <sql-type jdbc-type=”bigint” hibernate-type=”java.lang.Integer” not-null=”true”/>

    <sql-type jdbc-type=”numeric” hibernate-type=”java.lang.Integer”
    length=”3″ scale=”0″ precision=”0″ not-null=”false”/>
    <sql-type jdbc-type=”NUMERIC” hibernate-type=”java.lang.Integer”
    length=”3″ scale=”0″ precision=”0″ not-null=”false”/>
    <sql-type jdbc-type=”numeric” hibernate-type=”java.lang.Integer”
    length=”3″ scale=”0″ precision=”0″ not-null=”true”/>
    <sql-type jdbc-type=”NUMERIC” hibernate-type=”java.lang.Integer”
    length=”3″ scale=”0″ precision=”0″ not-null=”true”/>

    <sql-type jdbc-type=”numeric” hibernate-type=”java.lang.Integer”
    length=”” scale=”0″ precision=”3″ not-null=”false”/>
    <sql-type jdbc-type=”NUMERIC” hibernate-type=”java.lang.Integer”
    length=”” scale=”0″ precision=”3″ not-null=”false”/>
    <sql-type jdbc-type=”numeric” hibernate-type=”java.lang.Integer”
    length=”” scale=”0″ precision=”3″ not-null=”true”/>
    <sql-type jdbc-type=”NUMERIC” hibernate-type=”java.lang.Integer”
    length=”” scale=”0″ precision=”3″ not-null=”true”/>

    </type-mapping>

    #268635 Reply

    Haris Peco
    Member

    You have to set the sql-type jdbc-type parameter to jdbc type for your column from java.sql.Types.What is your database and what is type of column which you want reverse ?

    Regards

    #268638 Reply

    dkirvan
    Member

    If you look at the hibernate_reveng.xml data that I provided. I thought that I am trying to change the sql-type jdbc-type parameter to jdbc type for your column from java.sql. Can you provide me with the correct code for the hibernate_reveng.xml file that will convert the following fields to java.lang.Integer?

    The database is EnterpriseDB

    The Table is rol_type_attr
    The columns in the table that I am having problems with are:
    data_prec_cnt numeric(2,0)
    data_len_cnt numeric(3,0)
    rol_type_attr_id bigint

    When displaying the database in MyEclipse DB Explorer Table/Object Info tab the
    table rol_type_attr looks like:
    data_prec_cnt;numeric;2;0;;NO;NO;;
    data_len_cnt;numeric;3;0;;NO;NO;;
    rol_type_attr_id;int8;19;0;;NO;YES;;

    Thank you for your help
    David K.

    #268639 Reply

    dkirvan
    Member

    If you look at the hibernate_reveng.xml data that I provided. I thought that I am trying to change the sql-type jdbc-type parameter to jdbc type for your column from java.sql. Can you provide me with the correct code for the hibernate_reveng.xml file that will convert the following fields to java.lang.Integer?

    The database is EnterpriseDB

    The Table is rol_type_attr
    The columns in the table that I am having problems with are:
    data_prec_cnt numeric(2,0)
    data_len_cnt numeric(3,0)
    rol_type_attr_id bigint

    When displaying the database in MyEclipse DB Explorer Table/Object Info tab the
    table rol_type_attr looks like:
    data_prec_cnt;numeric;2;0;;NO;NO;;
    data_len_cnt;numeric;3;0;;NO;NO;;
    rol_type_attr_id;int8;19;0;;NO;YES;;

    Thank you for your help
    David K.

    #268671 Reply

    Haris Peco
    Member

    David,

    Please, try the following :
    <sql-type jdbc-type=”NUMERIC” precision=’0′ hibernate-type=”java.lang.Integer” />
    <sql-type jdbc-type=”INTEGER” hibernate-type=”java.lang.Integer” />
    <sql-type jdbc-type=”BIGINT” hibernate-type=”java.lang.Integer” />

    The jdbc driver return data types NUMERIC, INTEGER and BIGINT and there isn’t strong rules – it depends from database driver and version and sometimes this values are incorrect.Try experiment without length, precision and/or scale and after that add these values.

    Regards,

    #268688 Reply

    dkirvan
    Member

    No success. Bigint and numerics are still being converted to “long”. What else can I try? How do I know if the system is actually reading/using the hibernate.reveng.xml? It should not be that dificult to translate data types at conversion with Hibernate.

    Thank you for your assistance,
    David K.

    #268858 Reply

    cboudreau
    Member

    Hi,

    I’m having the same problem listed here but I’m trying to convert from TINYINT to boolean. Has this issue been resolved? I have tried to use the wizard to detect this datatype but I have not found a combination of values to perform this conversion successfully. Here is the line from the hibernate.reveng.xml file that the wizard generated:

    <type-mapping>
    <sql-type jdbc-type=”TINYINT” hibernate-type=”boolean” length=”1″ />
    </type-mapping>

    In the Java class, I see java.lang.Byte used and in the hibernate mapping I see java.lang.Byte as the hibernate type.

    My database is MySQL 5.0.37-community-nt with JDBC Driver mysql-connector-java-5.0.5.

    Do you have any more information on doing hibernate type conversions with MySQL? Any help would be appreciated.

    Here is the info from my version of MyEclipse:

    *** Date:
    Saturday, April 14, 2007 8:39:01 PM EDT

    ** System properties:
    OS=WindowsXP
    OS version=5.1
    Java version=1.5.0_08

    *** MyEclipse details:
    MyEclipse Enterprise Workbench
    Version: 5.1.1 GA
    Build id: 20070302-5.1.1-GA

    *** Eclipse details:
    MyEclipse Enterprise Workbench

    Version: 5.1.1 GA
    Build id: 20070302-5.1.1-GA

    Eclipse Platform

    Version: 3.2.2.r322_v20070119-RQghndJN8IM0MsK
    Build id: M20070212-1330

    Eclipse RCP

    Version: 3.2.2.r322_v20070104-8pcviKVqd8J7C1U
    Build id: M20070212-1330

    Eclipse Java Development Tools

    Version: 3.2.2.r322_v20070104-R4CR0Znkvtfjv9-
    Build id: M20070212-1330

    Eclipse Project SDK

    Version: 3.2.2.r322_v20070104-dCGKm0Ln38lm-8s
    Build id: M20070212-1330

    Eclipse Graphical Editing Framework

    Version: 3.2.2.v20070208
    Build id: 20070208-1315

    Eclipse startup command=-os
    win32
    -ws
    win32
    -arch
    x86
    -launcher
    C:\Program Files\MyEclipse 5.1.1 GA\eclipse\eclipse.exe
    -name
    Eclipse
    -showsplash
    600
    -exitdata
    12d8_4c
    -vm
    C:\Program Files\MyEclipse 5.1.1 GA\jre\bin\javaw.exe

    #268882 Reply

    dkirvan
    Member

    I am still waiting for help from the support team. I have not been able to resolve this issue. I am under a deadline but have ran into a brick wall with Hibernate. ❓

    #268891 Reply

    dkirvan
    Member

    Issue resolved.
    Looking in the .log file under the project/metadata folder it showed that i had errors in the hibernate.reveng.xml file (see message below). If there are any errors then nothing will get converted according to the reveng.xml file. I ran accross this on my own – which too long to find. I would have thought that someone at Myeclipse would have pointed me to this log file to check for such problems.

    !ENTRY com.genuitec.eclipse.hibernate 1 0 2007-04-16 09:58:39.102
    !MESSAGE Error processing rev-eng settings file
    !STACK 0
    org.hibernate.MappingException: Could not configure overrides from file: C:\MyEclipse\POC_EMD1\POC_EMD_PRJ2\src\hibernate\hibernate.reveng.xml
    at org.hibernate.cfg.reveng.OverrideRepository.addFile(OverrideRepository.java:79)
    at com.genuitec.eclipse.hibernate.wizards.GenerateArtifactsJob.run(GenerateArtifactsJob.java:272)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
    Caused by: org.hibernate.MappingException: jdbc-type: varchar2 is not a known JDBC Type nor a valid number
    at org.hibernate.cfg.reveng.JDBCToHibernateTypeHelper.getJDBCType(JDBCToHibernateTypeHelper.java:119)
    at org.hibernate.cfg.reveng.OverrideBinder.bindTypeMappings(OverrideBinder.java:217)
    at org.hibernate.cfg.reveng.OverrideBinder.bindRoot(OverrideBinder.java:30)
    at org.hibernate.cfg.reveng.OverrideRepository.add(OverrideRepository.java:130)
    at org.hibernate.cfg.reveng.OverrideRepository.addInputStream(OverrideRepository.java:109)
    at org.hibernate.cfg.reveng.OverrideRepository.addFile(OverrideRepository.java:75)
    … 2 more

Viewing 9 posts - 1 through 9 (of 9 total)
Reply To: Problem with reverse engineering and changing data types

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