-->
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.  [ 3 posts ] 
Author Message
 Post subject: collection of <element> not saving
PostPosted: Fri Jun 10, 2005 5:39 pm 
Newbie

Joined: Fri Jun 10, 2005 5:26 pm
Posts: 2
I have an IList where the members are strings. I used the configuration below and it created the tables as I would have expected, but my collection is not saving.

Code:
<list name="Locales" table="myTable" access="nosetter.camelcase-underscore" cascade="all">
    <key column="MyKey"/>
    <index column="posn"/>
    <element column="Name" type="string" length="10"/>
</list>


I debugged the code and found that in Cascades.cs (line 576)
the following line evals to "false"

if ( elemType.IsEntityType || elemType.IsObjectType || elemType.IsComponentType )
{
CascaedCollection(...) }

My other collections (e.g. one-to-many, many-to-many) are persisting but none of my "element" collections are.

Any help would be greatly appreciated.

Thanks,
Will


Top
 Profile  
 
 Post subject: Must use Flush to persist collection of <element>
PostPosted: Fri Jun 10, 2005 11:48 pm 
Newbie

Joined: Fri Jun 10, 2005 5:26 pm
Posts: 2
I was able to resolve my problem by calling Flush after my Save.

However, as I read the about @cascade options (7.7.1. Lifecycle objects), I expected "all" to persist my child collection without an explicit Flush. Am I incorrect?

Also, the Flush filled in all of my foreign keys to my parent object for other collections that were already persisting on Save. They were persisting, but neither the index nor key were being populated. Flush took care of that as well.

Regards,
Will


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 11, 2005 3:36 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes you have to call Flush to have your changes persisted. Flush is also called implicitly before executing queries and during transaction commit, subject to ISession.FlushMode setting.

That some objects are persisted on Save is an exception rather than the rule, it happens only for objects using "identity" id generator, because Save has to return the ID of a new object, and so it has to write the object to the database.


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