-->
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: Newbie to mappings
PostPosted: Thu Aug 31, 2006 4:17 am 
Newbie

Joined: Thu Aug 31, 2006 3:59 am
Posts: 3
I am a newbie to hibernate. I have 2 oracle tables: PRODUCT and TARRIF.

I need to join these two tables on the basis of PRODUCT.prodKey = TARRIF.prodKey.

Do i need to produce two seperate mapping files? product.hbm.xml and tarrif.hbm.xml? Or does the tarrif mapping need to be embedded in the product.hbm.xml?

Do i need to have a property of type Tarrif in the Product pojo?

In the end I want to be able to do a select query where I pull out the products and their respective tarrif.


Can someone give me any pointers to how my mapping files and pojos should look?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 31, 2006 3:55 pm 
Beginner
Beginner

Joined: Thu Aug 19, 2004 2:33 pm
Posts: 30
Location: CA, USA
See the reference doc. It has examples.

You can use one mapping for each table or put them into the same .hbm.xml file. It's up to you. I usually keep them separate. It makes it easier to find them if they are named after the table they describe and they only contain one table.

You don't use the "property" tag to define the relationship between the tables. You use the "many-to-one", "one-to-many", "set", etc tags based on the type of relationship. These will correspond to a java bean style getter on your java bean. For example, a "one-to-many" replationship will correspond to a method like this:

public List getTariffs() {...}


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.