facebook

myEclipse 5.1 hibernate reverse enginear database view

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

    davebond
    Member

    Can some one help, i am using myEclipse 5.1 and eclipse 3.2.1, using the reverse enginearing wizard, I can not get a sql server 2000 database view to work, the wizard does indeed reverse enginear the view but places all the columns in a composite key, I have manually tried to amend the hibernate reverse enginear xml file but again to no avail, I have in the past successfully used ant and manipulated the xml file to create the correct java class files but would prefer to use the the wizard.

    #265840 Reply

    Haris Peco
    Member

    You can’t change primary id in wizard, but you can define your primary key in reverse.eng file.
    You can set rev.eng file in page 2 of wizard and you should add this in file :


    <table name=”YOUR_TABLE”>
    <primary-key>
    <column name=”YOUR_ID”/>
    </primary-key>
    </table>

    You can add hibernate-tools.jar (and dependencies) in your ant build path and use ant file as well.

    Views haven’t primary key in database and there is no way that wizard decide what is hibernate ID.Hibernate ID is required with hibernate and our only choice is ‘use all column in views for ID’.

    Regards,

    #265853 Reply

    davebond
    Member

    Thank you for you response, I feel that I am going mad, I have tried all permutation, I generated the file firstly using page 3 of the wizard, then modified the file. It appears not to use the changes I have made, to the file, and I have saved the file.

    Here is my reverse enginear xml

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <!DOCTYPE hibernate-reverse-engineering PUBLIC “-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN” “http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd&#8221; >

    <hibernate-reverse-engineering>

    <table name=”V_CITY” schema=”dbo” catalog=”impensa”>
    <primary-key>
    <column name=”CITY_ID” />
    </primary-key>
    </table>

    </hibernate-reverse-engineering>

    i have tried to use a composite key
    <primary-key>
    <column name=”CITY_ID” />
    <column name=”LANG_ID” />
    </primary-key>

    I have tried to include the columns manually also

    <table name=”V_CITY” schema=”dbo” catalog=”impensa”>
    <primary-key>
    <column name=”CITY_ID” />
    <column name=”LANG_ID” />
    </primary-key>
    <column name=”CITY_ID” property=”cityId” />
    <column name=”LANG_ID” property=”langId” />
    <column name=”IS_ACTIVE” property=”isActive” />
    <column name=”LABEL” property=”label”/>
    </table>

    When I reverse enginear the file I still get a composite id for all the columns:
    <?xml version=”1.0″ encoding=”utf-8″?>
    <!DOCTYPE hibernate-mapping PUBLIC “-//Hibernate/Hibernate Mapping DTD 3.0//EN”
    http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd”&gt;
    <!–
    Mapping file autogenerated by MyEclipse – Hibernate Tools
    –>
    <hibernate-mapping>
    <class name=”com.expense.ov.VCity” table=”V_CITY” schema=”dbo” catalog=”impensa”>
    <composite-id name=”id” class=”com.expense.ov.VCityId”>
    <key-property name=”cityId” type=”java.lang.Integer”>
    <column name=”CITY_ID” />
    </key-property>
    <key-property name=”langId” type=”java.lang.Integer”>
    <column name=”LANG_ID” />
    </key-property>
    <key-property name=”isActive” type=”java.lang.String”>
    <column name=”IS_ACTIVE” length=”1″ />
    </key-property>
    <key-property name=”label” type=”java.lang.String”>
    <column name=”LABEL” />
    </key-property>
    </composite-id>
    </class>
    </hibernate-mapping>

    Then for some reason, having just closing MyEclipse and opening MyEclipse, all functions correctly. For those whom like to have an example. The following is working

    <table name=”V_CITY” schema=”dbo” catalog=”impensa”>
    <primary-key>
    <column name=”CITY_ID” />
    <column name=”LANG_ID” />
    </primary-key>
    </table>

    Thanks you for your help

    #265987 Reply

    Brian Fernandes
    Moderator

    Are you saying everything works exactly how you want it when you restart MyEclipse or is there still something you need? Does it stop working for the next RE run or do you need to restart MyEclipse only when you hand-edit the reveng.xml file?

    Do check your error log for errors and post relevant errors here. More details on obtaining a good log here: Posting Guidelines

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: myEclipse 5.1 hibernate reverse enginear database view

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