There are two points for me :
- I tend to consider that leaving a filtered collection as mutable is an
error. Consider mapping it as not mutable. Changes to the favorites should
then be done through an unfiltered collection.
- I you need to keep it mutable, is your collection considered a bag ? (I
am not used to fluent mapping, I use only xml mapping.) If yes and that is
what you intend, updates on bags can only be done by nhibernate through
full deletes followed by inserts of all elements in the bag, so you have no
solutions. If this is not what you wanted to do, you should map it as a set.
Le lundi 14 janvier 2013 14:56:17 UTC+1, Nistor Adrian a écrit :
>
> Hi,
>
> I ran into this problem that I can't solve for some time now:
>
> I have two entities: User and Job
>
> A User has FavoriteJobs. This is a many-to-many association with Job.
> Also, this association is filtered so that only active (not archived) jobs
> are fetched.
>
> The mapping for the FavoriteJobs association looks like this (using
> FluentNHibernate)
>
> HasManyToMany(x => x.FavoriteJobs)
> .Table("UserJob")
> .ParentKeyColumn("UserId")
> .ChildKeyColumn("JobId")
> .ApplyChildFilter<ExcludeArchivedJobsFilter>("IsArchived = :condition")
> .Cascade.None();
>
> A job can be archived and un-archived at any time from the application.
>
> When fetching users, the FavoriteJobs collection is populated with the
> right jobs, only the active ones.
>
> The problem is that when I want to save a User, all the jobs that were
> filtered are being treated as though their association has been broken and
> are deleted from the crossreference table (just like the user marked the
> filtered jobs as not being favorite anymore).
>
> I am wondering if there are any patterns to mark the filtered entries as
> being just filtered and not deleted.
>
> Something like disabling the filter from the mapping when there is an
> update event.
>
> I would appreciate any ideas,
> Adrian.
>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.