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.  [ 1 post ] 
Author Message
 Post subject: Two classes mapped to same table must be in correct order?
PostPosted: Thu Aug 27, 2009 12:13 pm 
Newbie

Joined: Thu Aug 27, 2009 11:53 am
Posts: 1
New to nhibernate here, apologies if this is a dumb question.

If I move the FunderSimple mapping before the Funder mapping my schema does not generate correctly. If I leave it as is below, it works.

Code:
<class name="Funder" table="funder">
    <id name="id">
      <generator class="identity" />
    </id>
    <property name="funder_name" />
    <property name="contact_name" />
    <property name="addr_line_1" />
    <property name="addr_line_2" />
    <property name="addr_line_3" />
    <property name="city" />
    <many-to-one name="state" column="state_id" foreign-key="FK_funder_state_id" fetch="join" />
    <property name="zip_code" length="10" />
    <property name="phone_number" length="30" />
   
    <property name="create_dt" update="false" not-null="true" />
    <many-to-one name="create_by" column="create_by" not-null="true" update="false" foreign-key="FK_funder_create_by" fetch="join" />
    <property name="last_update_dt" insert="false" />
    <many-to-one name="last_update_by" insert="false" foreign-key="FK_funder_last_update_by" fetch="join" />
   
  </class>

  <class name="FunderSimple" table="funder" schema-action="none" mutable="false">
    <id name="id">
      <generator class="identity" />
    </id>
    <property name="funder_name" />
    <property name="contact_name" />
    <property name="phone_number" />
  </class>



Is this by design? It seems as though the schema-action="none" sticks to the table_name and latter mappings to the same table will not generate the schema.

I'm doing it like this because I have another class named Contract which has a foreign key to the funder table. However, I don't need all the funder columns when referencing from the contract object.

Code:
<many-to-one name="funder_simple" column="funder_id"  foreign-key="FK_contract_funder_id" fetch="join" />


Funder does not inherit from FunderSimple.

Should I be using a different technique to fetch only a subset of columns from a foreign key table?


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

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.