-->
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: Please help with mapping to several tables!
PostPosted: Tue Mar 16, 2010 12:36 pm 
Newbie

Joined: Tue Mar 16, 2010 12:24 pm
Posts: 1
Hi, All,

I am new to hibernate. Please help with my problem and I will appreciate it a lot. Thanks.

I have 3 tables in database, property, address and loan.
In property table, there are 3 columns: propertyID, addressID and loanID;
In address table, there are 3 columns: AddressID, street, citystatezip;
In loan table, there are 3 columns: loanID, propertyID, and currentBalance.

in my class loan, i have datamembers as follow: loanID, currentBalance, street, citystatezip.I can simply map currentBalance from the database like following:
<hibernate-mapping package="mytest.package">
<class name="loan" table="loan">
<cache usage="read-only"/>
<id name="loanID" type="long" unsaved-value="-1">
<column name="loanID" sql-type="long" not-null="true"/>
<generator class="assigned"/>
</id>
<property column="currentBalance" name="currentBalance" not-null="false" type="long"/>
</class>
</hibernate-mapping>
However, i can not get the property address info like street and citystatezip since they are in different tables.

Could anyone please give me some suggestion? Thank you very much!!


Top
 Profile  
 
 Post subject: Re: Please help with mapping to several tables!
PostPosted: Tue Mar 16, 2010 5:17 pm 
Regular
Regular

Joined: Thu May 07, 2009 5:56 am
Posts: 94
Location: Toulouse, France
hi, you can use @SecondaryTable to do it. take a look at http://docs.jboss.org/hibernate/stable/ ... e/#d0e1758
I don't know the hibernate mapping (xml like) to do this but you should find it in hibernate docs

_________________
everything should be made as simple as possible, but not simpler (AE)


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.