Some days ago I opened an issue about wrong behavior of
Session.CreateFilter(..). The behavior happens only with collection of
elements ( not entity )
The reason is this:
if (IsFilter())
                        {
                                // Handle collection-fiter compilation.

                                IQueryableCollection persister =
_sessionFactoryHelper.GetCollectionPersister(_collectionFilterRole);
                                IType collectionElementType = 
persister.ElementType;
                                if (!collectionElementType.IsEntityType)
                                {
                                        throw new QueryException("collection of 
values in filter: this");
                                }

And a better explanation is that the filter is just a mangled query
around the entity collected, if there is no entity, such a query can't
be created. So in real life I used two mapping for the child, one as
element that I use when I update and work with the root entity in
memory ( this achieve better performance ) and one as entity that I
use when I want to do fancy GUI stuff. The final question is, can I
add a "shadow entity" to the current NH mapping, to temporary map the
element as an entity, in order to have the CreateFilter working with
elements too, or is such a strategy totally forbidden ?

Reply via email to