-->
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.  [ 4 posts ] 
Author Message
 Post subject: Define property names of foreign keys/composite id
PostPosted: Mon May 01, 2006 7:27 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
Hi all

I'm wondering how i can define propertie names of foreignkeys, which are building a composite id as well. I have 3 tables:

TBENUTZER
TPROFILE
TBENU_PROFIL_MATRIX

Table TBENUTZER contains all registered users, table TPROFILES all defined profiles and table TBENU_PROFIL_MATRIX is a matrix table which connects the benutzer with profiles.
TBENU_PROFIL_MATRIX only contains 2 columns, a foreign-key to TBENUTZER and a foreign-key to TPROFILE. Those foreign-key are building a composite ID of this table.

Now i was trying to define the properties in the reveng.xml file. My file looks like that:
Code:

<table schema="NAJSRE7_WEB" name="TBENUTZER" class="najsre7.model.Benutzer">
      <primary-key>
         <generator class="sequence">
            <param name="sequence">SEQ_TBENUTZER</param>
         </generator>
         <key-column name="ILAUFNUMMER" property="id" />
      </primary-key>

      <column name="SBENUTZERNAME" jdbc-type='' property="benutzerName" />
      <column name="SPASSWORT" jdbc-type='' property="passwort" />
      <column name="SEMAIL" jdbc-type='' property="eMail" />
      <column name="DLASTLOGIN" jdbc-type='' property="lastLogin" />
      <column name="IANZLOGIN" jdbc-type='' property="anzahlLogin" />
      <column name="SMUTUSER" jdbc-type='' property="mutUser" />
      <column name="SSTVUSER" jdbc-type='' property="stvUser" />
      <column name="DMUTDAT" jdbc-type='' property="mutDatum" />
      <column name="FK_TPER_IPERSNR" jdbc-type='' property="personId" />

      <foreign-key constraint-name="FK_TBENUSTAT_ISTATUS">
         <column-ref local-column="FK_TBENUSTAT_ISTATUS" foreign-column="ISTATUS" />
         <many-to-one property="benutzerStatus" />
         <set property="benutzer" />
      </foreign-key>
   </table>


   <table schema="NAJSRE7_WEB" name="TBENU_PROFIL_MATRIX" class="najsre7.model.BenutzerProfil">
      <primary-key>
         <key-column name="FK_TBENU_ILAUFNR" property="benutzer" />
         <key-column name="FK_TPROFIL_ILAUFNR" property="profil" />
      </primary-key>
      <foreign-key constraint-name="FK_TBENU_ILAUFNR">
         <column-ref local-column="FK_TBENU_ILAUFNR" foreign-column="ILAUFNUMMER" />
         <many-to-one property="benutzer" />
         <set property="profile" />
      </foreign-key>
      <foreign-key constraint-name="FK_TPROFIL_ILAUFNR">
         <column-ref local-column="FK_TPROFIL_ILAUFNR" foreign-column="ILAUFNUMMER" />
         <many-to-one property="profil" />
         <set property="benutzer" />
      </foreign-key>
   </table>
   
   <table schema="NAJSRE7_WEB" name="TPROFILE" class="najsre7.model.Profil">
      <primary-key>
         <generator class="sequence">
            <param name="sequence">SEQ_TPROFILE</param>
         </generator>
         <key-column name="ILAUFNUMMER" property="id" />
      </primary-key>
      <column name="SPROFIL" jdbc-type='' property="profilName" />
      <column name="SBESCHREIBUNG" jdbc-type='' property="beschreibung" />
      <column name="SMUTUSER" jdbc-type='' property="mutUser" />
      <column name="SSTVUSER" jdbc-type='' property="stvUser" />
      <column name="DMUTDAT" jdbc-type='' property="mutDatum" />
   </table>



The generated BenutzerProfil hibernate mapping file looks like that:

Code:
<hibernate-mapping>
    <class name="najsre7.model.BenutzerProfil" table="TBENU_PROFIL_MATRIX" schema="NAJSRE7_WEB">
        <composite-id name="id" class="najsre7.model.BenutzerProfilId">
            <key-many-to-one name="tbenutzer" class="najsre7.model.Benutzer">
                <column name="FK_TBENU_ILAUFNR" precision="22" scale="0" />
            </key-many-to-one>
            <key-many-to-one name="tprofile" class="najsre7.model.Profil">
                <column name="FK_TPROFIL_ILAUFNR" precision="22" scale="0" />
            </key-many-to-one>
        </composite-id>
    </class>
</hibernate-mapping>


so how can i define the both properties? now they have the names tbenutzer and tprofile, these i would like to change. Or is there a better solution to handle such a matrix table?

Kind regards
angela


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 01, 2006 7:55 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
as a solution i would like to have a collection in the Benutzer.java class which points to the profiles that are connected with this user.
And a collection in the Profile.java class which points to a set of users.

Is this something i can do with <idbag> ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 01, 2006 10:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
this is a many-to-many, correct ?

the reverse engineering does not support that (yet)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 02, 2006 1:44 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
max wrote:
this is a many-to-many, correct ?

the reverse engineering does not support that (yet)


hmmm ok :-/ yes it's a many-to-many relationship....so the only way is to define it directly in the hibernate mapping file i think.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.