-->
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.  [ 2 posts ] 
Author Message
 Post subject: Filter's subselect fails when used with fetchmode=subselect
PostPosted: Tue Oct 19, 2010 12:45 pm 
Newbie

Joined: Thu Oct 07, 2010 6:35 pm
Posts: 1
Summary:
The Hibernate filter's parameters are not populated when an entity's Collection is populated using a fetch mode of subselect.

Details:
I have a class (MyClass) with 2 collection properties: catalysts and attributeValues. Both are annotated to use a lazy fetch, and to use a subselect to do the fetching (see the sample code with annotations below).
The attributeValues collection is loaded with the same query that loads MyClass, using a fetch-join.
Code:
         select e
         from MyClass e
         left join fetch e.attributeValues

When I have the query configured to run WITHOUT the filter, it runs fine. i.e. the "filterAttributeIds" parameter to the query is correctly populated. (See code below for the filter which looks like: ATTRIBUTE_ID in ( :filterAttributeIds ) ).

However when I have the query configure to run WITH the filter, the initial select runs correctly (the "filterAttributeIds" are correctly populated).

However when I force the load of the catalysts collection by doing:
Code:
MyClass myclass = ...;
...
myclass.getCatalysts().size();

The subselect correctly includes the filter, but the "filterAttributeIds" parameter is not populated, and the query throws an appropriate exception.
This is all taking places in the context of a single Hibernate session.
My understanding is that the subselect is supposed to be the same query as the original select. In my case, the query is correct, however the parameters are no begin populated.
Is there something I must do to get the "filterAttributeIds" into the query for the catalysts, or is there a bug in Hibernate?
Code:
class MyClass {
        /*
        */
   @OneToMany(
      fetch = FetchType.LAZY,
      mappedBy = "policyDomainObject"
   )
   @MapKey(name = "catalyst")
   @Fetch(FetchMode.SUBSELECT)
   public Map<Catalyst, PolicyCatalystLink> getCatalysts()
   {
      if (null == m_Catalysts)
      {
         m_Catalysts = new HashMap<Catalyst, PolicyCatalystLink>();
      }
      return m_Catalysts;
   }
        /*
        */
   @OneToMany(
      cascade = CascadeType.ALL,
      mappedBy = "domainObject"
   )
   @Fetch(FetchMode.SUBSELECT)
   @Filters(
      value = {
         @Filter(
            name = "filterAttributeValuesByAttributeIds",
            condition="ATTRIBUTE_ID in ( :filterAttributeIds )"
         )
      }
   )
   public Collection<AttributeValue> getAttributeValues()
   {
      if (null == m_AttributeValues)
      {
         m_AttributeValues = new ArrayList<AttributeValue>();
      }

      return m_AttributeValues;
   }
}


Top
 Profile  
 
 Post subject: Re: Filter's subselect fails when used with fetchmode=subselect
PostPosted: Mon Nov 03, 2014 8:41 am 
Newbie

Joined: Mon Nov 03, 2014 7:54 am
Posts: 1
Please find patch attached in https://hibernate.atlassian.net/browse/HHH-7119 for hibernate-core-3.5.6-Final.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.