Impossible to use FitlerDefAttribute in NH1.2

Description

Looking at the implementation of FilterDefAttribute, then it is obvoius that the attribute cannot be used outside the class context, which documentation specifies is how a FilterDef should be declared:

.....
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field, AllowMultiple=true)]
[System.Serializable()]
public class FilterDefAttribute : BaseAttribute
.....

When placing the FilterDefAttribute elsewhere then on properties, you will get compile errors. When placed on a property, it will not be picked up by the HbmWriter.

The AttributeTargets.Class should at least be specified and then the HbmWriter must be responsible for placing the produced filter-def xml tag after the specification of the table mapping. Test that the FitlerDefAttribute work as expected, check if this behaviour exists in the upcoming NH2.1 release. Should be fixed there as well.

Environment

None

Activity

Show:

Steinar Dragsnes 
September 10, 2010 at 1:20 AM

At least some documentation could be useful here for how to use filters with NHMA. I've got some questions on this topic from different programmers and if you search the Spring.Net forum other questions around this topic is presented there.

NHMA is very useful and in our company it is highly valued to be able to see the mappings in the actual class we are working in, even though it slightly compromises the purity of the POCO pattern.

Pierre Henri Kuaté 
September 10, 2010 at 1:08 AM

Hi,
Yes, NHMA will continue to be supported.

It is a matter of scope; NHMA is designed to map classes (since that's what you can decorate with attributes).

Steinar Dragsnes 
February 25, 2010 at 4:06 PM

Too bad, I really like NHMA. Will NHMA continue to be supported in NH3, or is fluent the only future option.

Pierre Henri Kuaté 
October 22, 2009 at 4:59 PM

<filter-def> is a <hibernate-mapping> attribute, so it isn't covered by NHMA.

It could be, by writing a bunch of custom code, but I don't want to support it (would significantly increase the maintenance cost).

So, I suggest that you create a separated xml file for these elements.
This also applies to resultset, sql-query, database-object, etc.

Won't Fix

Details

Assignee

Reporter

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created April 3, 2009 at 2:42 AM
Updated September 10, 2010 at 1:20 AM
Resolved October 22, 2009 at 4:59 PM
Who's Looking?