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.  [ 2 posts ] 
Author Message
 Post subject: Is this going to afect performance?
PostPosted: Mon Jan 16, 2006 3:23 pm 
Newbie

Joined: Mon Jan 09, 2006 1:32 am
Posts: 3
Company class
with 2 subclasses Clients and Banks.

A Company can have companies child (like in Category CaveatEmptor)
but a company can't be child from another child. so this is only one level.
and Clients can have none, one or more banks. and viceversa. (to represent contracts between them)

this is the mapfile moreless, the idea.

<class Company table=company>

<manytoone companyFather class=Company />
<Set childCompany onetomany />

<subclass client>
<set bank manytomany table=contracts >
</subclass>

<subclass bank>
<set client manytomany table=contracts >
</subclass>

</class>

the resulting relationship between company table and contracts ends with 4 relation, having in contracts just 2 ids, client_id and bank_id..

it looks nice, but i dont know if this is going to afect, in that case, i should part the table company in two tables, clients and banks, and make the third table (contracts) in order to relate them in a many to many.


Top
 Profile  
 
 Post subject: one more thing i forgot to write
PostPosted: Mon Jan 16, 2006 8:25 pm 
Newbie

Joined: Mon Jan 09, 2006 1:32 am
Posts: 3
the relatioinship is bidirectional, and there are 2 types of contracts that a client can have with a single bank, so, in the table contracts, i need a 3rd column contractType, but in the map file, a can't do this.
i need to add a property tag, (contractType)

Code:
<class name=Company table=company>
....
   <subclass name="Client" discriminator-value="CLIENT">
            .....
      <many-to-one name="company"
                class="Company"
                access="property"
                cascade="none"
                outer-join="false"
                foreign-key="id_company_fk">
         <column name="id_company_parent" not-null="false" unique-key="unique_company_per_level"/>
      </many-to-one>
<!-- this is what i was talking about, the table resulting from this map file looks crazy, and i dont know if its ok,  -->
      <set name="companyChilds"
          cascade="all-delete-orphan"
          inverse="true"
          lazy="true"
          batch-size="10">
         <key column="id_company_father"/>
         <one-to-many class="Company"/>
      </set>
         .......
      <set name="banks"
          table="contracts"
          lazy="true"
          inverse="true"
          cascade="save-update">
         <key column="client_id"/>
         <many-to-many class="Client" column="bank_id"/>
      </set>
   </subclass>
   <subclass name="Bank" discriminator-value="BANK">
           ....
      <set name="clients"
          table="contracts"
          lazy="true"
          cascade="save-update">
         <key column="bank_id"/>
         <many-to-many class="Bank" column="client_id"/>
      </set>
   </subclass>
</Class>



the property tag for contract type must be into the set, but i can't, is there other way. Should i make a 3rd class?, Contract and map it to a table, and then make the relation many-to-one collection between Contract and Bank, and Contract and Client.


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