-->
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.  [ 2 posts ] 
Author Message
 Post subject: Empty collections, null or empty?
PostPosted: Wed Nov 02, 2005 6:40 am 
Newbie

Joined: Fri Oct 21, 2005 4:49 am
Posts: 13
I've been using Hibernate 3.0.5 for a few weeks now with the help of the HiA book. Some issues I've discovered don't seem to be answered in the book however.

If a category has no items and you call category.getItems(), does Hibernate return null or an empty set/list?

It seems that using an HQL query followed by .list() will always return an empty list but requesting the list of associated objects from a persisted object (as above) will sometimes returns null.

Is this the designed behaviour? Wouldn't it be nicer to always return an empty collection? Is there a flag somewhere to enable this behaviour?

Thanks for your help


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 02, 2005 7:11 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Initialize the collection in the declaration: private Set categories = new HashSet();

Please continue in the regular User Forum.


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