-->
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: Antipattern - Accessing an uninitialized collection
PostPosted: Tue Apr 20, 2004 10:01 am 
Newbie

Joined: Mon Feb 09, 2004 10:00 pm
Posts: 15
The AssertionFailure that occurs when a user is accessing a child collection in the parent during the load of the parent has been pretty well documented and discussed.

http://www.hibernate.org/Documentation/FAQsFromTheForum#A32
http://forum.hibernate.org/viewtopic.php?t=928523&highlight=isinitialized

We were having the same problem and don't want to introduce a Hibernate-specific check (if (Hibernate.isInitialized(coll)) ...) into our domain model. At the end of the last post above, Gavin stated:

Quote:
If only add() didn't have a return value, I could do it internally


Before reading this post I was wondering why the AssertionFailure is thrown in the first place. If the collection is initializing, simply add the new object to the templist collection until the hibernate collection proxy is initialized. At that time, all of the objects in templist are copied over. I'm probably missing something else here since Gavin's reply about return value on add() doesn't make much sense to me. Wouldn't this approach work? Does it cause other unwanted side-effects?

The primary concern here is that this is the first bit of code we have written that introduces an anti-pattern into our domain model. This is the only case using Hibernate (so far) that we have to do something unexpected (from our domain models perspective) to work nicely with our OR mapping solution.


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.