@Ernst Naezer:
Thanks a lot! The assignment works!
I called InterceptorFactory.Create = delegate { return new
SearchInterceptor(); };
right before ActiveRecordStarter.Initialize().

@Germán Schuager:
Your approach is great! But unfortunately, this didn't work out
without Windsor Container.

@Jimmy Shimizu:
Yes, this would be my initialization of choice, but AR 1.0 RC3 does
not support NHibernate 2.0.

So finally I've got full-text search with Lucene.NET. =)



On 26 Sep., 10:03, Jimmy Shimizu <[EMAIL PROTECTED]> wrote:
> I'm not really sure where you read the part about the SearchInterceptor
> on that URL, but that has been changes since a few months back...
>
> It is suggested that you use NHibernate listeners, but that needs
> NHibernate/NHibernate.Search 2.0 afaik.
>
>     ISessionFactoryHolder holder = 
> ActiveRecordMediator.GetSessionFactoryHolder();
>     NHibernate.Cfg.Configuration configuration = 
> holder.GetConfiguration(typeof(ActiveRecordBase));
>
>     configuration.SetListener( ListenerType.PostUpdate, new 
> FullTextIndexEventListener() );
>     configuration.SetListener( ListenerType.PostInsert, new 
> FullTextIndexEventListener() );
>     configuration.SetListener( ListenerType.PostDelete, new 
> FullTextIndexEventListener() );
>
> That would be triggered on all scope and works for me. You don't even
> need new instances for each Listener, I use the same one for Update,
> Insert and Delete and that works fine.
>
>
>
> burkhard_m wrote:
> > Hi,
>
> > I'm trying to implement full-text search functionality with
> > NHibernate.Search 1.2.1.4000, Lucene.NET 2.0.0.4 and
> > Castle.ActiveRecord 1.0.3.0.
>
> > The main problem is, that I have to register a SearchInterceptor in
> > order to hook NHibernate.Search into NHibernate so that it can
> > automatically maintain the search index.
> > (Source:http://using.castleproject.org/display/AR/Using+NHibernate.Search+wit...
> > )
>
> > Well, most examples based on NHibernate suggest to open a new session
> > with the SearchInterceptor attached:
>
> >             using (ISession session =
> > Global.SessionFactory.OpenSession(new SearchInterceptor()))
> >             using (IFullTextSession fullTextSession =
> > Search.CreateFullTextSession(session))
> >             using (NHibernate.ITransaction tx =
> > session.BeginTransaction())
> >             { ... }
>
> > But in ActiveRecord this is different. Using the code above creates a
> > new session which is not linked to the SessionScope / TransactionScope
> > of ActiveRecord. So any rollback fails or session timeouts may occur.
> > Instead I would rather prefer to init the full-text session like this:
>
> >             using (var tx = new TransactionScope())
> >             {
> >                   var factory =
> > ActiveRecordMediator.GetSessionFactoryHolder().GetSessionFactory(typeof(Des­cription));
> >                   var session = tx.GetSession(factory);
> >                   IFullTextSession fullTextSession =
> > NHibernate.Search.Search.CreateFullTextSession(session);
>
> >                   ...
> >             }
>
> > Unfortunately the code above throws a HibernateException:
> > "\r\nThe session interceptor was not a SearchInterceptor.\r\nIn order
> > to use Full Text Query, you must open the session with a
> > SearchInterceptor. Like this:\r\nsessionFactory.OpenSession(new
> > SearchInterceptor());\r\n"
>
> > Well, but that's not what I want, because the MSSQL Profiler tells me,
> > that this call always leads to another db transaction and additional
> > login.
> > So I tried to figure out if there is any other solution ... and there
> > is! NHibernate.Cfg.Configuration offers the SetInterceptor() method.
> > Afterwards my intialization code looked like this:
>
> >        IConfigurationSource source =
> > ActiveRecordSectionHandler.Instance;
> >        ActiveRecordStarter.Initialize(typeof(Description).Assembly,
> > source);
>
> >        ISessionFactoryHolder holder =
> > ActiveRecordMediator.GetSessionFactoryHolder();
> >        NHibernate.Cfg.Configuration configuration =
> > holder.GetConfiguration(typeof(ActiveRecordBase));
>
> >        configuration.SetInterceptor(new SearchInterceptor());   //  <-
> > adds the interceptor
>
> >        SearchFactory.Initialize(configuration,
> > holder.GetSessionFactory(typeof(Description)));
>
> > But the code above still throws a HibernateException with the same
> > error message as above.
> > So how do I hook NHibernate.Search into ActiveRecord & NHibernate
> > without using OpenSession?
> > In my humble opinion, I have to access the Interceptor directly
> > through ActiveRecord. But that didn't work out either, because the
> > property is readonly. Of course I could use Reflection to access it,
> > but I don't want to mess around with internal code.
> > Do you have an idea?
>
> > The activerecord documentation wasn't quite helpful, too:
> >http://www.castleproject.org/activerecord/documentation/trunk/advance...
>
> > By the way, here are my app settings:
>
> > <activerecord isWeb="false">
> >   <config>
> >  <add key="hibernate.connection.driver_class"
> > value="NHibernate.Driver.SqlClientDriver" />
> >  <add key="hibernate.dialect"
> > value="NHibernate.Dialect.MsSql2000Dialect" />
> >                    <add key="hibernate.connection.provider"
> > value="NHibernate.Connection.DriverConnectionProvider" />
> >                    <add key="hibernate.max_fetch_depth" value="3"></add>
> >                    <add key="hibernate.connection.connection_string"
> > value="ConnectionString = ${myConnectionString}" />
> >                    <add key="hibernate.show_sql" value="true" />
> >                    <add key="hibernate.search.default.directory_provider"
> > value="NHibernate.Search.Storage.FSDirectoryProvider,
> > NHibernate.Search" />
> >                    <add key="hibernate.search.default.indexBase"
> > value="Index"/>
> >                    <add key="hibernate.search.analyzer"
> > value="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>
> >            </config>
> >   </activerecord>- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to