-->
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: Question about ensuring POJO association correctness
PostPosted: Thu Feb 23, 2006 3:21 pm 
Newbie

Joined: Wed Feb 22, 2006 5:53 pm
Posts: 4
Pages 70-71 talk about the importance of ensuring POJO association correctness, and present the addChildCategory() convenience method. It goes on to explain:

Quote:
Because we would like the addChildCategory() to be the only externally visible mutator method for the child categories, we make the setChildCategories() method private. Hibernate doesn’t care if property accessor methods are private or public, so we can focus on good API design.


That's great, but what prevents someone from mistakenly adding a child by using the Collection's add() method instead of the addChildCategory() method? That is, couldn't they just do exactly what's presented on page 70?:

Code:
aParent.getChildCategories().add(aChild);


The child gets added, but its parent won't get set and it won't get removed from its previous parent's collection (if any).

Thanks and sorry if I'm just being dumb and missing something obvious.


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.