-->
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: Mapping help
PostPosted: Fri Sep 09, 2005 2:05 pm 
Newbie

Joined: Sat Jan 29, 2005 7:09 am
Posts: 11
Hi - I have the usual order/order items object model i.e. the order object contains a Set of items. However, the underlying database is not broken down into order and orderitem tables, instead there is a single orders table that maps orderDates and products directly i.e.:

1 | 1/1/05 | 1 | 4
2 | 1/1/05 | 2 | 6
3 | 1/1/05 | 3 | 4
4 | 2/1/05 | 1 | 7
5 | 2/1/05 | 2 | 1
...

where the first column is id, the second is orderDate, the third is productId and the fourth is quantity.

How do I go about mapping this to my order/orderItem object model?

Hibernate version: 3.0.5


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 9:50 pm 
Senior
Senior

Joined: Wed Jul 13, 2005 4:31 pm
Posts: 142
Location: Seattle, WA
One way is to have a single class - say OrderAndItem that maps to the table. It can use composite key (orderid, itemid). You can write queries and/or updates that pull up all OrderAndItem for a given orderid, or itemid.

The other is to have views on the db that give the order/orderItem view of the table and map the views to hibernate classes order/orderitem.

Essentially means that you have to do the translation to a normalized form, either at the database level or in java code.

Hope this helps.


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.