-->
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: Problem creating Parent and Child at the same time ?
PostPosted: Sun Feb 27, 2005 10:27 am 
Newbie

Joined: Thu Feb 03, 2005 11:36 am
Posts: 11
Hi, I have a class with a one to many relation to itself (Categories contains Categories). I have no problem setting them right, except when I try to create the parent category and the child category on one turn...

Category parentCat = new Category();
parentCat.setTitle(CAT_SIGNATURE);

Category childCat = new Category();
childCat.setTitle(CHILDCAT_SIGNATURE);
childCat.setParentCategory(parentCat);

parentCat.getChildCategories().add(childCat);

The last line produce a null exception because the Set is null (or course, there's no magic as the model class doesn't have any code to do such a thing).

I've tried to flush and commit but the Set is not created by Hibernate.

From other part off my application (when simply adding a category without putting any child in it) the Set is created when the category object is loaded by Hibernate.

In that case, must I need to create a new Set by myself ?


Thank you


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.