-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Reverse Engineering XML: Forcing Unidirectional Mapping
PostPosted: Mon Nov 26, 2007 10:15 am 
Newbie

Joined: Mon Nov 26, 2007 9:54 am
Posts: 3
All,

The project I am currently working on involves the generation of cfg.xml and hbm.xml files from the DB schema. There is one table called p_d_intervals and it describes the available intervals of time. It contains only 4 rows, no foreign keys and an auto-generated primary key.

Then, there is a p_d_log table that contains log entries. This table has a column that is a foreign key referring to the p_d_interval.id.

The problem is that whenever I try to generate the schema. it produces two object links in between the table. Each log entry contains one interval type which refers to the interval of time for the log entry. This is correct. Then, there is a field in the interval type that is a SET containing all log entries of that interval type. This would make sense in reality, but not with our object model. This is an unnecessary waste of space. How do i remove this from my object model without affecting the DB schema????

Please note that this is my first trial at hibernate.

I am using the Bauer/King Java Persistence with Hibernate (Manning). I noticed that in the only real example for reverse engineering, they do not fully demonstrate how to block bi-directional object mapping, because it is a self-referring table. The example FROM THE BOOK is here:

Code:
        <foreign-key constraint-name="FK_NEXT_MESSAGE">
            <many-to-one property="nextMessage"/>
            <set exclude="true"/>  <!-- I AM GUESSING: this needs to be in my code somewhere, but where?? -->
        </foreign-key>


appropriate excerpt from MY reveng.xml:

Code:
    <table name="pub_disable_log">
        <foreign-key constraint-name="pub_disable_log_interval_id_fkey" foreign-table="pub_disable_intervals">
            <column-ref local-column="interval_id" foreign-column="ID"/>
            <many-to-one property="interval"/>
        </foreign-key>
    </table>

    <table name="pub_disable_intervals">
              <!-- WHAT GOES HERE??? -->
    </table>


Thanks for any and all help you may provide.

-Hiren
-EMAIL: hhiranan AT gmail DOT com

PS. I am at work and currently dealing with the issue, so any and all assistance whenever possible is much appreciated. Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 26, 2007 12:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
do like the example and have a foreign-key element with the apropriate name for it and mark is having the set excluded.

OR write a custom reveng strategy that returns false for the method excludeForeignKeyAsCollection

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: SWEEEEEEEEET
PostPosted: Mon Nov 26, 2007 3:45 pm 
Newbie

Joined: Mon Nov 26, 2007 9:54 am
Posts: 3
Thanks...
Problem's solved.

Code:
    <table name="pub_disable_log">
        <foreign-key constraint-name="pub_disable_log_interval_id_fkey" foreign-table="pub_disable_intervals">
            <column-ref local-column="interval_id" foreign-column="ID"/>
            <many-to-one property="interval"/>
        </foreign-key>
    </table>

    <table name="pub_disable_intervals">
        <foreign-key constraint-name="pub_disable_log_interval_id_fkey">
            <set exclude="true"/>

        </foreign-key>
    </table>


-H


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.