facebook

Unidirectional Hibernate Mapping

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

    stefanmader
    Member

    Hello,

    I have a 1:n association between 2 tables, A and B.

    How can I generate a unidirectional Hibernate mapping between them?

    This is, I want class B to have a reference to class A, but it shall not be possible to navigate from A to B.

    Is this possible?

    cheers
    Stefan

    #284448 Reply

    Brian Fernandes
    Moderator

    stefan,

    To do this, you need to create a custom reveng.xml file in your project. Here is an example:

    <?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" >
    
    <hibernate-reverse-engineering>
        <table name="A" schema="SCHEMANAME">
            <foreign-key constraint-name="FOREIGNKEYNAME">
                <set exclude="true" />
            </foreign-key>
        </table>
    </hibernate-reverse-engineering>

    Please replace SCHEMANAME/FOREIGNKEYNAME with appropriate names corresponding to your tables. If you already have a hibernate.reveng.xml file, please merge the contents above with your existing file. If your existing file already has a <table> element referencing table A, you will need to add the <foreign-key> section to it.

    On page 2 of the RE wizard, point the rev-eng settings file field to this file and click Finish.

    Hope this helps.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Unidirectional Hibernate Mapping

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