-->
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: filters and joined-sublass inheritance
PostPosted: Tue Feb 22, 2005 6:26 am 
Newbie

Joined: Tue Feb 22, 2005 5:47 am
Posts: 1
I am using Hibernate version: 3b4

I ran into the following issue when using filters on a hibernate mapping with inheritance.

When having a baseclass "A" and a subclass "A1" as a "joined-subclass", enabling a filter in the baseclass does not seem to have any effect when querying for objects of the subclass A1.


My mapping document looks like this:

Code:
<hibernate-mapping>
   <class name="A" table="A">
      ...
      <joined-subclass name="A1" table="A1">
        ...
      </joined-subclass>

      <filter name="hideTemporaryObjects" condition="status=1" />
   </class>
</hibernate-mapping>



This is the code to retrieve the objects:
Code:
  session.enableFilter("hideTemporaryObjects");

   // this query returns the filtered dataset as expected
  Query query = session.createQuery("from A");

  // this query will return an unfiltered dataset
  query = session.createQuery("from A1");



I expected that enabling the filter on class A will consequently filter all sublasses.

Declaring the filter under the <joined-sublass> element is not possible either because it is not allowed by the DTD.

But how can I enable the filter for my subclasses?

Thanks in advance,
Bernado.




[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 23, 2007 8:38 am 
Newbie

Joined: Wed Nov 08, 2006 6:17 am
Posts: 5
I'm running into what, I believe, is the exact same issue with NHibernate-1.2.0.GA.

I've done some minor debugging on this, and it appears to me that this behaviour is related to the fact that the EntityJoinWalker plainly ignores the enabledFilters.

Code:
public EntityJoinWalker(..., IDictionary enabledFilters)
{
  ...
  SqlStringBuilder whereCondition = WhereString(Alias, uniqueKey, uniqueKeyType, batchSize)
    //include the discriminator and class-level where, but not filters
    .Add(persister.FilterFragment(Alias, CollectionHelper.EmptyMap));
  ...
}


I'm currently further investigating. The enabledFilters are probably ignored for a good reason, but then again, maybe not? Maybe the CollectionHelper.EmptyMap should actually be enabledFilters? Not sure if I could put this on Jira...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 24, 2007 4:04 am 
Newbie

Joined: Wed Nov 08, 2006 6:17 am
Posts: 5
This is getting ugly for me. I was really fond of the filter, but, as I see it now, it's unusable when using joined-subclasses.

I tried to quickhack it into the EntityJoinWalker, but it appeared not so straightforward as I hoped. Positions of named parameters get fucked up. I _could_ spend time delving into that, but then again: I'll probably be quicker taking out the filter and adjusting my data layer.


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.