-->
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.  [ 5 posts ] 
Author Message
 Post subject: Anyone try out the new filter functionality yet?
PostPosted: Thu Sep 02, 2004 4:52 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
I've got the business requirement to implement a dual layer of filtering for certain classes of objects. We're currently using 2.1.x but hibernate 3 looks like it might already be doing what I eventually want to accomplish.
One layer is some date constraining and the other is whether or not the data in question belongs to a specific business entity by traversing a bit of a hierarchy.

I'm curious as to whether or not the new filter functionality would work in the following scenarios:

-Support for use in Criteria API (looks like the CriteriaLoader et al. has been reworked to support).

-If being used by the Criteria API how 'complex' can the filter condition be. i.e. typically in the Criteria environment if you want to reference another table like if A.B.someColumn = 'someValue' you'd have to set up an Alias. When using the filter is this possible in either case (i.e. with or without the Alias)

-Given a class that might be referenced from multiple one-to-manys can you simply set the filter up at the class level (on the 'many' side) rather than have to set it up for each of the Collections ('one' side'). This isn't a big show stopper, just would make for easier implementation, i.e. I could implement the filter definition in one spot rather than 25.

-Along the same vein as above, if a collection is being lazy loaded will the same filter logic be applied? It seems that it might by looking at the source code.

I'll most likely get around to do a prototype on our app but since the package names changed it's not just as simple as dropping the .jar in. Before I get to that I need to go and check out Oracle Workspace Manager for some more magic requirements :)

So, if anyone is already trying this out, I'd love to hear your experiences so far. If it is already built in then that is better than me trying to jack it in myself.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 11:04 pm 
Beginner
Beginner

Joined: Mon May 03, 2004 1:25 pm
Posts: 31
I'm using Hib3 filters and they work great. We have a legacy database that had some arch relationships and other oddities that made mapping it a real joy. Dynamic Filters really helped out alot.

As for you questions:
-- in the filter you reference the actual DB column name, so I'm not sure if you could use aliases or not, but I don't know how you could as it's part of a mapping not part of a query, so you don't know what the aliases are when you create the filter..

-- you can set up the filter on both the collection and the class, but I think (I haven't tested this at all, the filters are the same in my case so I wouldn't notice a difference) that the when the class is being referenced as a collection, the class level filter will be ignored. As for referencing from the many side, it doesn't make sense as the one side can't be filtered or else there wouldn't be a relationship to build.

I really like the functionality and it's working very well for us.

Tim


Top
 Profile  
 
 Post subject: Re: Anyone try out the new filter functionality yet?
PostPosted: Thu Sep 02, 2004 11:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
VampBoy wrote:
-Support for use in Criteria API (looks like the CriteriaLoader et al. has been reworked to support).


Yup.

Quote:
-If being used by the Criteria API how 'complex' can the filter condition be. i.e. typically in the Criteria environment if you want to reference another table like if A.B.someColumn = 'someValue' you'd have to set up an Alias. When using the filter is this possible in either case (i.e. with or without the Alias)


The filter usually refers only to the filtered entity of collection. I am very openminded about allowing other things, but we need to see real concrete usecases.

Quote:
-Given a class that might be referenced from multiple one-to-manys can you simply set the filter up at the class level (on the 'many' side) rather than have to set it up for each of the Collections ('one' side'). This isn't a big show stopper, just would make for easier implementation, i.e. I could implement the filter definition in one spot rather than 25.


There are reasons why it is best done at the collection side (to do with <joined-subclass> mappings) and we are still investigating this. Note if you just want to reuse the code of a filter definition, you can just include an XML external entity.

Quote:
-Along the same vein as above, if a collection is being lazy loaded will the same filter logic be applied? It seems that it might by looking at the source code.


Yes, the collection filter is applied.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 03, 2004 1:41 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
Thanks for the responses guys, and Gavin glad to see you still milling about with the common folk ;)

Fantastic that it works with the Criteria API and that it wasn't neglected :D
And also fantastic that it works with lazy loading etc.

Like I said in my original post, having to set the filters up at the collection level isn't a big issue although there IS support at the class level though right? (unless I misread something)

As far as a use case for allowing chaining properties this is the case I have but I'm not sure I need to use filters for it in the end.

Actually, let me take a step back for a moment, what I had really been interested for with the use of filters was to narrow down results based on EFFECTIVE/INACTIVE date strategies. i.e. our application will allow the user to go back in time to fix data that they may have had screwed up and re-run some transaction processing. However, it looks like I'm going to try to leverage Oracle's Workspace Manager to accomplish most, if not all, of that functionality. It buys us the ability to let the user work in a 'sandbox' and change everything to their heart's content and then either accept or toss their changes. So in essence, I think the Hibernate side of this becomes one dimensional ignoring the time concept.

The other concept is that I when I search for certain type of records I only want to see the records that belong to a certain physical location. Now there are few tables that share this behavior and I would really like a generic way to accomplish this.

However, the more and more I think about it, perhaps the filter isn't the best tool for the job. Rather, for the 3 or 4 places I'll need to do it maybe I write the code to build the query to narrow the results. It's a bit different than if I was trying to handle the Effective Date gear. So maybe I don't have a concrete use case for it. Let me think about it some more.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 16, 2004 11:15 am 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
Well, we're full bore into using the filtering now and it is working fantastic so far to tackle our temporal data architecture that we're implementing.

My question on the A.B, etc chaining was 'silly' as the filter fragments are SQL and not HQL, therefore I can simply join at my leisure.

However, I still have a question regarding the following:

My Original Question:
-Given a class that might be referenced from multiple one-to-manys can you simply set the filter up at the class level (on the 'many' side) rather than have to set it up for each of the Collections ('one' side'). This isn't a big show stopper, just would make for easier implementation, i.e. I could implement the filter definition in one spot rather than 25.

Gavin's Response about 2 months ago:
There are reasons why it is best done at the collection side (to do with <joined-subclass> mappings) and we are still investigating this. Note if you just want to reuse the code of a filter definition, you can just include an XML external entity.

How is the investigation going? I've come to a spot where I am going to need a filter for about 13 or 14 of my objects based on a date based query. Most of the query is generic except for the table names involved. We're going to look at generating this filter at the class level with Xdoclet but it would still be nice if any one to manys would pick it up rather than having to define it everywhere the class is referenced.


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