-->
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.  [ 4 posts ] 
Author Message
 Post subject: Composite aggregation
PostPosted: Tue Jan 23, 2007 10:26 am 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
In all rels there is a Cascade option.
The cascade=CascadeType.ALL option is similar to making the relationship a composite aggregation since when the owner is deleted or persisted, the update will be cascaded down to the aggregated entity.

However, strictly speaking it's not an composite aggregation.
There is no restriction on the number of entities that can have a reference to the composite aggregated object.

For example, say I have an entity Person which composite aggregates an Address entity.

@OneToOne(cascade=CascadeType.ALL)
public Address getHomeAddress() {
return this.address;
}

It is possible for me to create a number of Person entities which have the same Address object.
This is not composite aggregation relationship.
My question is there anyway / annotation a composite relationship can be achieved in Hibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 24, 2007 5:06 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@Embeddable

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 26, 2007 12:39 pm 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
emmanuel wrote:
@Embeddable
]Thanks, I got that from the spec alright.
However that only suffices for 1:1, it won't work for 1:M.
that's the way the JPA spec is right now.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 11:28 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@CollectionOfElements will do the job of one to many (Hibernate specific)

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.