-->
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: <list problems
PostPosted: Thu Jan 07, 2010 8:11 am 
Newbie

Joined: Thu Jan 07, 2010 8:08 am
Posts: 3
Hi Folks!
I have some problems where you might be able to help.
I try to map a class containing some lists, where the order is
relevant.

Code:
namespace NAMESPACE
{
    public class CLASSNAME
    {
...
        private List<ITEMCLASS> internalCollection;
...
        protected virtual ICollection<ITEMCLASS> PersistenceList
        {
            get
            {
                return internalCollection;
            }
            set
            {
                internalCollection.Clear();
                internalCollection.AddRange(value);
            }
        }
...
    }
}

when i use the following mapping it works:
Code:
                <set name="PersistenceList" cascade="all-delete-orphan" generic="true">
                        <key column="KEYCOLUMN"/>
                        <one-to-many class="NAMESPACE.CLASSNAME, ASSEMBLY"/>
                </set>

But since this mapping does not preserve the order of elements, i
tried to do this:


Code:
...
        protected virtual IList<ITEMCLASS> PersistenceList
        {
            get
            {
                return internalCollection;
            }
            set
            {
                internalCollection.Clear();
                internalCollection.AddRange(value);
            }
        }
...

with the following mapping:


Code:
<list name="PersistenceList" cascade="all-delete-orphan" generic="true">
  <key column="KEYCOLUMN"/>
  <index column="LISTINDEXCOLUMN"/>
  <one-to-many class="NAMESPACE.CLASSNAME, ASSEMBLY"/>
</list>


Now the database tables for elements contained in the lists remains
empty after adding one element of the main class.
The data in the other properties of the main class is stored
correctly.
Is there anything i forgot to make it work?

Kind regards,
Christian


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.