-->
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: Problem with reusing same mapping class
PostPosted: Thu Feb 23, 2006 1:25 am 
Newbie

Joined: Thu Feb 23, 2006 1:03 am
Posts: 7
Location: Los Angeles, CA
I have 2 classes.
User and Address

with following mapping



Code:
 
<class  name="ABC.User, ABC"
    table="Users">
    <id name="ID" column="UserID" type="Int32" unsaved-value="0">
      <generator class="native" />
    </id>
    <property name="Username" column="Username" type="String"/>
    <property name="Password" column="Password" type="String"/>
    ....
    ....
    ....
    <set name="Addresses" inverse="true" cascade="all" access='NHibernate.Generics.GenericAccessor, NHibernate.Generics' >
      <key column="ContactID"/>
      <one-to-many class="ABC.Address, ABC"/>
    </set>
  </class>


  <class name="ABC.Address, ABC" table="Addresses">
    <cache usage="read-write" />
    <id name="ID" column="AddressID" type="Int32" unsaved-value="0">
      <generator class="native">
      </generator>
    </id>
    <property name="Address1" column="Address1" type="String" length="50" />
    <property name="Address2" column="Address2" type="String" length="50" />
....
....

    <many-to-one cascade="save-update"

                     name='User'

                     access='NHibernate.Generics.GenericAccessor, NHibernate.Generics'

                     class='ABC.User, ABC'

                     column='ContactID' />   
  </class>


Now i want to make a search form, and since result coming as

Code:
User
   Addresses
       Address
       Address

I can't display it in DataGridView.
I decide to make a separate class UserAddress(flat)
which contain User->Address one-to-one relationship.
I start doing mapping as:
Code:
  <class  name="ABC.User, ABC"
    table="Users">
    <id name="ID" column="UserID" type="Int32" unsaved-value="0">
      <generator class="native" />
    </id>
    <property name="Username" column="Username" type="String"/>
    <one-to-one name="????" class="ABC.Address, ABC"/>
  </class>


And have no idea how to map
in code i want to have
Code:
UserAddress
    id;
    Username;
    Address1;
    ....
    ....
    Zip

That object is easy bind to grid, and sorting will work.
Anyone can help me to learn NHibernate???
Maybe its other way of doing it??
I tried IQuery but it return ArrayList,but i need also field names
Thanks a lot
gerasha


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.