NHibernate Filters

1,293 views
Skip to first unread message

liam

unread,
Apr 20, 2009, 8:41:53 PM4/20/09
to Fluent NHibernate
Is there a way to configure NHibernate filters for use with auto
mapping? I want to implement multitenancy by having a field on every
table that identifies the tenant.

Paul Batum

unread,
Apr 22, 2009, 8:24:10 AM4/22/09
to fluent-n...@googlegroups.com
Hi Liam,

I haven't worked with filters so my knowledge is a little hazy, please correct me if I am on the wrong track here.

I presume you would implement the filters themselves using the fluent interface, so are you asking about how to automap an extra tenant column for each table in your application? In this case, do your entities have the tenant field defined on them, or are you doing something tricky with the persistence of the entities to see that the tenant value is set transparently without representing it directly on the entity?

Paul Batum

liam

unread,
Apr 25, 2009, 2:01:33 AM4/25/09
to Fluent NHibernate
I have not added the tenant descriminators yet but I expect that each
entity would have a tenant field since that is probably easiest. The
part I dont understand is how to setup the filter mapping using the
fluent interface.

http://74.125.95.132/search?q=cache:vR-X1s1ZBqcJ:www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/filters.html+nhibernate+filters&cd=1&hl=en&ct=clnk&gl=au&client=firefox-a

Paul Batum

unread,
Apr 26, 2009, 10:37:29 AM4/26/09
to fluent-n...@googlegroups.com
Hmm. For some reason I thought there was a fluent interface for defining filters. Typically in this sort of scenario I use the google code search for the xml element name such as "filter-def". In this case its turned up no results so it seems that I was mistaken.

So what I suggest is that you define your filters using good old hbm-xml. There are a few ways to mix hbm xml and fluent mappings, some of which are covered here:
http://wiki.fluentnhibernate.org/show/FluentConfiguration

Let me know how it goes.

Paul Batum
Reply all
Reply to author
Forward
0 new messages