-->
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: receiving the @identity of an item in a collection
PostPosted: Tue Oct 16, 2007 10:56 am 
Newbie

Joined: Tue Sep 25, 2007 6:43 am
Posts: 16
Hello,

this is for 1.2

I have a failing testcase and wonder, if someone could point me the right direction...

theme = getTheme();
p = new Product(31, Guid.NewGuid().ToString(), "bla");
r = new ThemeProductRelation(p, theme);

themeDao.SaveOrUpdate(theme);
productDao.SaveOrUpdate(p);

theme.AddProductRelation(r);
themeDao.SaveOrUpdate(theme);

Assert.IsTrue(theme.ProductRelations[0].Id > 0); // fails

Theme.AddProductRelation(ThemeProductRelation) is like this:

public virtual void AddProductRelation(ThemeProductRelation
relation)
{
relation.Theme = this;
if (productRelations == null)
productRelations = new List<ThemeProductRelation>();
productRelations.Add(relation);
}

All of this follows closely the recommendation of the reference pdf ~pg. 140

Same goes for the xml...

<class name="Theme"
table="Kit"
lazy="true">
<id name="Id"
column="KitID"
unsaved-value="0">
<generator class="identity" />
</id>
<bag name="ProductRelations"
table="ProductKit"
inverse="true"
cascade="all-delete-orphan">
<key column="KitID" />
<one-to-many class="ThemeProductRelation" />
</bag>
</class>

What can I do for this test to pass?

Thanks for any help,

Jan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 16, 2007 1:22 pm 
Newbie

Joined: Tue Sep 25, 2007 6:43 am
Posts: 16
Just found out, I need to call flush() to make this work


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.