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: ISet not being initialised when new object created
PostPosted: Mon Sep 28, 2009 2:42 pm 
Newbie

Joined: Wed Aug 05, 2009 3:46 pm
Posts: 2
Hi,

I have an object which has an ISet defined for it, I believe I have all the mapping correct but when I create a new instance of the object the ISet is null, meaning I cannot populate it. This is strange as other object which have sets initialise an empty ISet on creation.

If I load the collection from the database it loads the ISet fine, which again is strange.

Does anyone have any ideas, why this could be happening?

Thanks for any help,

Kev

My set is declared in the object as follows:

<set name="WinnerAmounts" table="QuizWinnerAmount" generic="true" cascade="all-delete-orphan" inverse="true" lazy="true">
<key column="QuizID"/>
<one-to-many class="Models.QuizWinnerAmount, Models"/>
</set>

The corresponding object, which belongs to the set is defined as follows, this has a composite key:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Models.QuizWinnerAmount, Models" table="QuizWinnerAmount">
<composite-id unsaved-value="any">
<key-many-to-one name="Quiz" column="QuizID" class="Models.Quiz, Models" lazy="proxy"></key-many-to-one>
<key-property name="WinnerPlace" type="Byte"></key-property>
</composite-id>
<property name="Percentage" type="Decimal" not-null="true"></property>
<property name="MaximumAmount" type="Decimal" not-null="true"></property>
</class>
</hibernate-mapping>

Thanks for any help again.

Kev


Top
 Profile  
 
 Post subject: Re: ISet not being initialised when new object created
PostPosted: Tue Sep 29, 2009 2:52 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
How do you create the new object ? If you do it like this:

QuizWinnerAmount qwa = new QuizWinnerAmount();

you're responsible for initializing the set yourself !

_________________
--Wolfgang


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.