facebook

Hibernate reverse engineering doesn’t work

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

    KIG
    Participant

    I’m using MyEclipse 4.1 GA and want to generate Hibernate mapping files from an existing Firebird database. First of all, the default mapping files are generated.

    Table “Account”:

    create table "ACCOUNT"(
    "ACCOUNTID" VARCHAR(36) PRIMARY KEY not null,
    "ACCOUNTNO" VARCHAR(10) not null,
    "DESCRIPTION" VARCHAR(200) not null,
    "BALANCE" NUMERIC(18,2) default 0 not null,
    "CUSTOMERID" VARCHAR(36) not null)
    

    The generated XML file looks like this:

    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- 
        Mapping file autogenerated by MyEclipse - Hibernate Tools
    -->
    <hibernate-mapping>
        <class name="test.hibernate.data.Account" table="ACCOUNT">
            <id name="accountid" type="java.lang.String">
                <column name="ACCOUNTID" length="36" />
                <generator class="uuid" />
            </id>
            <property name="accountno" type="java.lang.String">
                <column name="ACCOUNTNO" length="10" not-null="true" />
            </property>
            <property name="description" type="java.lang.String">
                <column name="DESCRIPTION" length="200" not-null="true" />
            </property>
            <property name="balance" type="java.lang.Double">
                <column name="BALANCE" precision="18" not-null="true" />
            </property>
            <property name="customerid" type="java.lang.String">
                <column name="CUSTOMERID" length="36" not-null="true" />
            </property>
        </class>
    </hibernate-mapping>

    After that I tried to modify the settings for the property “balance”. The hibernate.reveng.xml looks as follows:

    <hibernate-reverse-engineering>
    
        <table name="ACCOUNT" catalog="Default Catalog">
            <column name="ACCOUNTNO" />
            <column name="BALANCE" jdbc-type="java.math.BigDecimal" property="bal"/>
        </table>
    </hibernate-reverse-engineering>

    Whe I start the hibernate wizard once again I get the same result as before. How can I specify custom mapping settings?

    #245724 Reply

    Brian Fernandes
    Moderator

    KIG,

    Are you editing the reverse engineering file by hand or using page 3 of our RE wizard? I would just like you to confirm that the reverse engineering file specified on Page 2 of the RE wizard does indeed have the modifications you mentioned above.
    My concern is that you might be editing the wrong file here (if you are doing anything by hand)

    When you created your connection profile (or when you edit your current profile), on the second page of the Profile wizard, can you make sure “Display all schemas” is checked and not “Display default schema only”.
    Reconnect to the database using this option, and go through the RE customization process again, on page 3, specify the customization you need. Does it work for you now?

    Finally, if the above options did not work, what is the name of the catalog which contains your table? I see catalog = “Default Catalog” in the RE file, but I suspect that is incorrect. Can you manually edit that file and replace the catalog attribute with the correct value? Or try removing the attribute entirely.

    It is possible that some errors are generated in your error log during mapping, could you please have a look at them and paste ane relevant errors here?
    Instructions here: Posting Guidelines

    Best,
    Brian.

    #245728 Reply

    KIG
    Participant

    Brian,

    thanks a lot for your help, it worked! I could solve the problem once I’ve removed the catalog attribute from the hibernate.revenge.xml file.

    Best regards,

    Klaus

    #245729 Reply

    Brian Fernandes
    Moderator

    Klaus,

    I’m glad it’s working. But could you tell me if you tried the first two steps I outlined above?

    1) Did you generate the RE file by hand or using our wizard?
    2) Did you have Show default schema only chosen in your profile? Did you try changing this value to Show all schemas?

    Best,
    Brian.

    #245732 Reply

    KIG
    Participant

    Brian,

    here are the answers.

    1.) I’ve modified the RE by using the wizard. The first time I modified the file by hand was when I removed the catalog attribute.
    2.) The option display all schemas was always enabled.

    If it would help you, I could investigate some time to resolve the catalog attribute problem. Probably it’s related to Firebird. Anyway, I’ll post my test results in the next days.

    Regards,
    Klaus

    #245733 Reply

    Brian Fernandes
    Moderator

    Klaus,

    Thank you for that information. Yes, this does look like a firebird issue and a wrong catalog attribute being picked up and written to the file.
    If you modify mapping details for any other tables, you will have to similarly edit the file and remove that attribute.

    Sorry for the inconvenience, I have filed a report against this behaviour so that we can take care of it internally.

    Best,
    Brian.

    #245734 Reply

    KIG
    Participant

    Brian,

    in the Database Explorer the tables belong to the leaf node DEFAULT CATALOG. I don’t know Firebird so detailled, but it seems to me that you can’t specify a catalog name.

    Could you change the catalog attribute from mandatory to optional?

    Regards,

    Klaus

    #245735 Reply

    Brian Fernandes
    Moderator

    Klaus,

    in the Database Explorer the tables belong to the leaf node DEFAULT CATALOG.

    Yes, I guessed that that would be the cuase of this issue.

    Could you change the catalog attribute from mandatory to optional?

    We will certainly try to do something so that this attribute is not unnecessarily generated.

    We will try to fix this in MyEclipse 4.1.1 which is due late Feb or early March.

    Thank you for helping track this down and sorry once again for the inconvenience caused until 4.1.1.

    Best,
    Brian.

    #248705 Reply

    Hi,
    I have tried RE and it generates all POJO and DAO, but it seems that it doesn’t create JSF forms, linke in flash-tutorial.
    What can be wrong?
    Thank you forwardly,
    Oleh

    #254172 Reply

    grinch_xk
    Member

    i use MyEclipse 4.1.1 ,but the hibernate.reveng.xml dosen’t work ! can you tell me why ?
    i used MyEclipse 4.1.1 and eclipse 3.1.2

    #254232 Reply

    Brian Fernandes
    Moderator

    Grinch,

    hibernate.reveng.xml is a file used internally by the reverse-engineering tool, not something that needs to be either modified by you OR used in a runtime hibernate application.
    Could you tell us what you want to do and what exactly isn’t working? Please answer all questions asked here: Posting Guidelines

    Best,
    Brian.

Viewing 11 posts - 1 through 11 (of 11 total)
Reply To: Hibernate reverse engineering doesn’t work

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