-->
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: How to map more than one foreign keys as Composite key.
PostPosted: Thu Sep 10, 2009 5:09 am 
Newbie

Joined: Thu Sep 10, 2009 2:48 am
Posts: 2
java classes are,

class Account
{
private long acctId;
private doule balance;
private UserHoldings[] objUserHoldings;
}
class Positions
{
private long positionsId;
private String positionsName;
}

class UserHoldings
{
private Account account;
private Positions position;
private long value;
private Date current;
}

i'm newbie to Hibernate, i don't know how to make UserHolding hibernate mapping file. can anyone help me? In UserHolding class accountId and positions id as Composite key.


Top
 Profile  
 
 Post subject: Re: How to map more than one foreign keys as Composite key.
PostPosted: Thu Sep 10, 2009 9:04 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Looks like you've just got a basic one-to-many mapping that is navigable in both directions.

Just map one class at a time, and you'll do fine.

Here's a little tutorial on mapping one-to-many associations in Hibernate:

http://jpa.ezhibernate.com/Javacode/lea ... sociations

Also, here's a slightly more complex domain model that is completely mapped, so you can get a good idea of how it looks when multiple classes are mapped interchably within a domain model:

http://jpa.ezhibernate.com/Javacode/lea ... itymapping

Image

http://jpa.ezhibernate.com/Javacode/lea ... itymapping

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.