-->
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: Indexed Collections when using a Where in the mapping
PostPosted: Thu Oct 06, 2011 6:51 pm 
Newbie

Joined: Sat Jan 29, 2011 8:36 am
Posts: 3
Hi, Looking for some insight.

I have a OneToMany mapping like this:

Code:
    <list name="addresses" cascade="all-delete-orphan" where"HIDDEN='Y"" >   
        <key column="PERSON_ID" not-null="true" />   
        <list-index column="SORTORDER" />   
        <one-to-many class="something.Address"/>
        etc


Everthing works well except when a "logical" delete occurs (the HIDDEN column is set to 'Y'). I filter the collection
at fetch time using the where clause. In this way, I am only working with addresses that are not "deleted". I dont want to physically delete for historic purposes.
The problem is really with spring MVC not being able to post back beacause of the SortOrder (index) not aligning, but I want to fix this problem upstream.

Example:


If a person has 5 addresses and one of them (the 3rd) was "deleted" using HIDDEN = 'Y' then Hiberante will return 4 addresses (perfect),
but the 4 records will have a gap in the actual collection

Code:

DB:

ADDRESS_ID PERSON_ID  SORTORDER HIDDEN
5           45            0       N
6           45            1       N
7           45            2       Y
8           45            3       N
9           45            4       N

The created Java List


ADDRESS   PERSON     SORTORDER  HIDDEN
5           45            0        N
6           45            1        N
8           45            3        N
9           45            4        N




3rd item is missing, and the sortOrder has a gap and Spring does not like that apparently.

Does anyone have any ideas how to manage this? Is there a way I can force a recalculate of the sortOrder when an item is set to HIDDEN=Y
so that HIDDEN=Y are at the bottom of the list therefore when the collection is fetched using the where clause the sortOrder is still intsact.
Hope this makes sense. I dont want to throw code at this if I dont have to.

Thanks

-J


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.