2007/11/4, T. Papke <[EMAIL PROTECTED]>:
> Thank you for your answer.
>
> What is the difference between tapestry-hibernate module and an per
> Thread session instanced by tapestry-ioc? Is there any disadvantage when
> switching?

A per thread session instance is just what you get with
tapestry-hibernate, and in the future there will probobly be
transaction handling etc etc included. So the disadvantage would be
that you loose that if you do it on your own.

>
> Could you send some code snipplets of your tapestry-ioc
> hibernate-session service?
>
> Is this something like the good old HibernateUtil implementation or did
> you handle something special because of opening and closing of
> transaction per request?

We have a custom built session/transaction handling system of services
so its hard for me to send a snipplet..
My suggestion is to make a per thread service with the session inside,
get it from that service. then it will work for hibernate-search.

>
>     public static SessionFactory buildSessionFactory(){
>         SessionFactory sessionFactory=null;
>         try {
>             sessionFactory = new AnnotationConfiguration().configure()
>                     .buildSessionFactory();
>         } catch (Throwable ex) {
>             throw new ExceptionInInitializerError(ex);
>         }
>          return sessionFactory;
>     }
>
>     @Scope("perthread")
>     public static Session buildHibernateSession(SessionFactory
> sessionFactory ){
>         return sessionFactory.openSession();
>     }
>
> I have looked into the code of FullTextSessionImpl in hibernate-search.
> Do you know why they are casting between org.hibernate.Session to
> org.hibernate.classic.Session?
I have no idea.. :)
>
> Thanks a lot,
> Thomas
>
> Ted Steen schrieb:
> > This happens because the session becomes a proxy when you make a service of 
> > it.
> > I guess you have a thread scope on the hibernate session? well, then
> > tapestry-ioc will wrap the session in a proxy that will give you a new
> > session per request.
> >
> > Actually its neither a tapestry-hibernate nor hibernate-search issue.
> > the problem is that lucene appears to try to cast the session, which
> > fails because its hidden inside the proxy.
> >
> > Our solution was to wrap the session in a service and make that
> > service per-thread instead.
> >
> > Hope it helps!
> >
> > 2007/11/3, T. Papke <[EMAIL PROTECTED]>:
> >
> >> Hi,
> >>
> >> in my project, i currently use hibernate 3.2.5 (and hibernate-search
> >> 3.0.0) together with tapestry 5.0.6 (and tapestry-hibernate module). The
> >> "normal" Hiberate works as excpeted, but the hibernate fulltext-search
> >> runs against an exception - i think because of wrong init of the
> >> hibernate session inside the tapestry module.
> >>
> >> I do:
> >> ....
> >> FullTextSession fullTextSession = Search.createFullTextSession(
> >> hibernateSession );
> >> ....
> >>
> >> If i try to get a FullTextSession object, i got:
> >> "java.lang.ClassCastException: Processing of request failed with
> >> uncaught exception: $Session_11606936826 cannot be cast to
> >> org.hibernate.classic.Session"
> >>     at
> >> org.hibernate.search.impl.FullTextSessionImpl.<init>(FullTextSessionImpl.java:69)
> >>     ....
> >>
> >> If i create the hibernate session by myself, everything thems to be
> >> working.
> >>
> >> Is that a bug of Hibernate-search or a bug of tapestry-hibernate module?
> >>
> >> Thanks a lot,
> >> Thomas
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >>
> >
> >
> >
>
>


-- 
/ted

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to