-->
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.  [ 6 posts ] 
Author Message
 Post subject: FilterDefAttribute
PostPosted: Tue Mar 31, 2009 3:11 am 
Beginner
Beginner

Joined: Tue Jan 02, 2007 5:53 pm
Posts: 42
Location: Bergen, Norway
Hi!

I'm using NH1.2 and the accompanying NHibernate.Mapping.Attributes. This works out very well, and I'm keen on upgrading once 2.1 is out the door, especially since the attributes are included into the main assembly.

The last days I've been trying to define filters using NHibernate.Mapping.Attributes but this does not go well. By reading the documentation then it seems like the FilterDefAttributes should be applied outside the class. When looking at their implementation, they can only be applied on fields, indexers and properties. When applying the FilterDefAttribute on fields or properties, the filter definitions are not picked up by the HbmSerializer. How should the FilterDef attribute be used? Is this a bug? Does it work as documentation states in the upcoming 2.1 release?

Currently I've worked around the issue by creating the filter definitions manually in code and added them to the NHibernate configuration before AddAssembly is invoked. The FilterAttribute works as expected.

Thanks for any input on this,

_________________
Cheers,
Steinar.


Last edited by steinard on Thu Apr 02, 2009 6:55 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 01, 2009 1:28 pm 
Newbie

Joined: Wed Apr 01, 2009 1:05 pm
Posts: 1
Location: Richmond, VA
I'm having a problem with the filter-def as well.

I put the filter-def tag outside of the class in the .hbm file as shown in the documentation. When I run the app, I get an error when the .AddAssembly is implemented that says the class tag is an invalid child element of the hibernate-mapping element. If I put the filter-def tag inside the class tag, i get an error saying the filter-def tag is an invalid child element to the class element.

Any info on this? FYI -- I am a newbie :)

Thanks for any help you can provide.

Kim


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 02, 2009 2:09 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
I can't help with the attributes, but for the other problem you have to put the filter-def outside and after the class definition (if you have one).

Do you have the hibernate source code available ? There're schema definition files for the mapping and configuration (in src/nhibernate). You can put those into "C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas" and VS helps you with IntelliSense and xml validation.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 02, 2009 6:52 pm 
Beginner
Beginner

Joined: Tue Jan 02, 2007 5:53 pm
Posts: 42
Location: Bergen, Norway
Hi!

Still, since attributes are included in the 2.X releases, then this behaviour, at least for the attributes should be fixed in that release. I can live with this as 1.2 will be upgraded soon and I can define what I need programmatically and add my instances to the session factory.

For defining the Filter-Def in plain xml, then I think this should work. I've been looking at the NH1.2 source when it comes to grasping what the filter, filter-def and filter-helper does and there are unit tests demonstrating that part. When it comes to the attributes, there is not much unit tests and that darn generated DomainModel unit test is just plain unreadable.

Anyway, I guess I will be ambandoning the attributes as well and use fluent interfaces once 2.1 is released. Hopefully filter definition will work out better there.

_________________
Cheers,
Steinar.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 03, 2009 3:48 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
You can open an issue and submit a test case:

http://nhjira.koah.net/secure/Dashboard.jspa

_________________
--Wolfgang


Top
 Profile  
 
 Post subject: http://nhjira.koah.net/browse/NHMA-23
PostPosted: Fri Apr 03, 2009 5:50 am 
Beginner
Beginner

Joined: Tue Jan 02, 2007 5:53 pm
Posts: 42
Location: Bergen, Norway
Hi!

The issue has been raised. You cannot even place the attribute outside the class because then you will get compile errors. Pretty obvious that something must be done. Maybe Pierre had something else in mind when he created/generated that attribute, but I haven't seen any documentation or found anything this passed last week on how the attribute, with it's current implementation, is meant to be used. Hopefully the solution described in the issue should be sufficient to solve this problem.

_________________
Cheers,
Steinar.


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