-->
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: Parent-child relationship between independent objects.
PostPosted: Wed Nov 05, 2008 11:00 am 
Newbie

Joined: Tue Jun 24, 2008 6:06 am
Posts: 5
I'm having a hibernate model. It's quite complex.
The root object in my hierarchy (let's call it a 'user') is really, really big.

There are four objects that are quite independent - Users, Carts, Products and Characteristics.
By independent I mean - no cascading between them.
A User has a collection of Carts, a Cart has a collection of Products, a Product has a collection of Characteristics.
This is a really big simplification. There are a ton of other objects attached to all of the four objects. Cascading was switched on between the objects in the hierarchies of the four main objects.

I had to write a web service that could work with this object model.

I wanted to do something RESTful-like.
I did it like this:
A. I wanted to supply CRUD operations to the four independent objects.
B. Between the independent objects I put only IDs: If you download a Cart you get a collection of Product.id so you can get all the products by using getProduct(id)

'B' proved to make my life a living hell - if you want a Cart, to get the collection of Product.id, I had to get all the Products with its full hierarchy - which is really unnecessary.

Question:
What is the best way to fix that?
Do I have to create getProduct() with no Carts in it and getProducts(Cart c)?

Question2:
When I return a single Product, do I return the Cart associated with it (via Product.getCart())? I don't think so, because then Cart is big. But the client should have a way to know which Product is linked to which Cart.


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.