facebook

Reverse engineering – hibernate.reveng.xml

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

    Eric Clemons
    Member

    I’m trying to use hibernate reverse engineering on some tables in myeclipse.

    It works, but my first problem was that many of the tables are views, or have no primary keys or foreign keys defined at the DB level. And unfortunately they’re not going to be. But I know what columns contain the unique ids.

    I figured out from the forums here that I could manually edit hibernate.reveng.xml with lines like:
    <table name=”MY_TABLE”…
    <primary-key>
    <key-column name=”MY_TABLE_ID” />
    </primary-key>
    </table>
    To force the reverse engineering ot use MY_TABLE_ID as an id rather than creating a composite-id.

    That worked. But now I’m trying to manually define a foreign key the same way.
    I’ve tried several things, but the reverse engineering doesn’t seem to honor this one. It seems to me this should work:

    <table name=”MY_TABLE”…
    <foreign-key foreign-table=”MY_OTHER_TABLE”>
    <column-ref local-column=”OTHER_ID” foreign-column=”OTHER_ID” />
    <many-to-one property=”otherTable”/>
    </foreign-key>
    </table>

    There are no errors during the reverse engineering, it still generates all the POJOs but it still doesn’t generate the references between the objects like it does when there is a true foreign key defined in the database. Am I doing this wrong, or does this not work for foreign keys like it did for primary keys?

    #273628 Reply

    Riyad Kalla
    Member

    steerpike,
    I’m sorry for the delay in responding. I sent your question off to one of our hib developers and he didn’t have any ideas as to why this isn’t working. Unfortunately I don’t either, I haven’t used the custom hibernate rev-eng strategy file rules before.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Reverse engineering – hibernate.reveng.xml

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