-->
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: Help to model Parent/Child/Sibling associations
PostPosted: Tue Aug 09, 2005 1:07 am 
Newbie

Joined: Mon Apr 18, 2005 2:45 am
Posts: 3
I'm testing the Hib-annotation water. I try to implement a class ProductCategoryRollup as following:

Composite Id:
* String productCategoryId;
* String parentProductCategoryId;
* Date fromDate;

I want to do these because a particular category can rollup to multiple parent-categories and a have a effective starting date.

ProductCategoryRollup has the following associations to other instances of the same class:

* ManyToMany parentProductCategories; a category can have multiple parents
* ManyToMany childProductCategories; a category can have many children
* ManyToMany siblingProductCategories; a category can have many siblings

The parent/child relations is implemented as shown belowed. But I'm stuck on the sibling relation. Is there a way to model the sibling relation without using query?

Code:
@Entity(access = AccessType.FIELD)
public class ProductCategoryRollup {

    @Embeddable(access = AccessType.FIELD)
    class ProductCategoryRollupID implements Serializable {
        String productCategoryId;   // id-ne
        String parentProductCategoryId; // id-ne
        Date fromDate;  // date-time
        ...
    }
    @EmbeddedId
    ProductCategoryRollupID id = new ProductCategoryRollupID();

@ManyToMany
// Let hibernate fillin the JoinTable
Set<ProductCategoryRollup> parentProductCategoryRollup;

@ManyToMany(mappedBy="parentProductCategoryRollup")
Set<ProductCategoryRollup> childProductCategoryRollup;

//How to model the Sibling relation?


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.