You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kalle Korhonen <ka...@gmail.com> on 2009/02/05 00:57:30 UTC

Re: T5: getting current hibernate session (per-thread) from singleton-service

I just hit the same problem "cannot be cast to ...SessionImplementor" while
trying to use Hibernate session in a service that auto-populates some
entries to the database at start-up (so obviously not in request context).
Did anybody find a solution for this?

Kalle


On Wed, Jul 9, 2008 at 10:08 AM, Britske <gb...@gmail.com> wrote:

>
> Wow I love that. Somehow I mistakenly thought it didn't work that way,
> thanks.
>
> As a related question :
> is there a way to get the 'real' session instead of the proxy on a call to
> getSession()
>
> The reason I'm asking is that in a lot of cases I want to use (Hibernate's)
> DetachedCriteria's, so I can make a criteria, pass that as a parameter to a
> repository and let the repository get the current session and create a real
> criteria. (For reasons of seperation)
>
> This is done through detachedCriteria.getExecutableCriteria(getSession());
>
> However this always gives a classCastException, like:
> java.lang.ClassCastException: $Session_11b08fbaf1e cannot be cast to
> org.hibernate.engine.SessionImplementor.
>
> for a related post (similar problem) see:
>
> http://www.nabble.com/Hivemind-creates-proxy-Hibernate-Session-td9845916.html
>
> Therefore I need the 'real' object.
> diong getSession().getSessionFactory().getCurrentSession() would solve my
> problem, since that would be both the session of the current thread and the
> real object, but (as described in method 2 of my post) the context assigned
> to be tapestry-hibernate isn't there when accessing the session in this
> way.
>
> Any suggestions on how to solve this as well? Much apreciated!
>
>
>
>
>
>
> Howard Lewis Ship wrote:
> >
> > If you are using tapestry-hibernate, the injectable Session service is
> > a perthread proxy.  It can be shared across threads, but each method
> > invocation on the proxy is redirected to a real per-thread Hibernate
> > session.
> >
> > On Wed, Jul 9, 2008 at 9:27 AM, Britske <gb...@gmail.com> wrote:
> >>
> >> I found some partial references on the list, but nothing that really
> >> answered
> >> the question, so:
> >> How can I get the current (per-thread) hibernate-session (as configured
> >> through tapestry-hibernate) from a singleton custom tapestry service?
> >>
> >> For reference:
> >> I have a MySingleton-class build as a tapestry service.
> >> MySingleton.getSingleton().getCurrentSession() should give me the
> current
> >> session (thread-bound) as managed by tapestry-hibernate.
> >> This would enable me to access the current session from any class (not
> >> just
> >> components or tapestry services)
> >>
> >>
> >> I tried 3 methods, 2 of which don't work, and 1 I'm not certain
> >>
> >> Method 1:
> >> build the MySingleton-class and inject Session at constructortime.
> >>
> >> Problem:  the hibernate session that is created on constructor-time
> stays
> >> assoaciated with MySingleton  (correct?). So this doesn't give a
> >> session-per-thread.
> >>
> >>
> >> Method 2:
> >> build the MySingleton-class and inject HibernateSessionSource
> >> getCurrentSession(){
> >>   return hibernateSessionSource.getSessionFactory().getCurrentSession();
> >> }
> >>
> >> Problem:
> >>
> >> but this gives error:
> >> org.hibernate.HibernateException: No CurrentSessionContext configured!
> >> I think this happens because the way the session is accessed bypasses
> the
> >> tapestry-hibernate session-in-view filter (HibernateSessionManager)
> which
> >> takes care of providing the context.
> >>
> >> Is there any way to make getSessionFactory() aware of the
> >> HibernateSessionManager? So the above works?
> >>
> >>
> >> Method 3:
> >> build the MySingleton-class and inject ProperyShadowBuilder  and
> >> HibernateSessionManager
> >>
> >> I figured this calling hibernateSessionManager.getSession() would give
> me
> >> the needed context (which lacked from method 2) . The problem is that
> >> HibernateSessionManager is not a singleton either.
> >> I thought this could be bypassed by doing :
> >>
> >> getCurrentSession(){
> >> return shadowBuilder.build(hibernateSessionManager, "session",
> >> Session.class);
> >> }
> >>
> >> However this still doens't ensure (I think) that hibernateSessionManager
> >> belongs to the current thread.
> >>
> >>
> >> Can anyone shed some light on this? I would highly appreciate it!
> >> Cheers,
> >> britske
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/T5%3A-getting-current-hibernate-session-%28per-thread%29-from-singleton-service-tp18365296p18365296.html
> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
> >
> >
> > --
> > Howard M. Lewis Ship
> >
> > Creator Apache Tapestry and Apache HiveMind
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/T5%3A-getting-current-hibernate-session-%28per-thread%29-from-singleton-service-tp18365296p18367496.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T5: getting current hibernate session (per-thread) from singleton-service

Posted by Kalle Korhonen <ka...@gmail.com>.
Sure, easy to do that in my application code. However, this is a service
(that injects a session into it) in a Trails library that builds on
tapestry-hibernate. I can change the library, but I was just wondering if
it'd be worth and possible to fix in tapestry-hibernate itself.

Kalle


On Wed, Feb 4, 2009 at 9:20 PM, Howard Lewis Ship <hl...@gmail.com> wrote:

> HibernateSessionManager.getSession()
>
>
> On Wed, Feb 4, 2009 at 9:16 PM, Kalle Korhonen
> <ka...@gmail.com> wrote:
> > Noo.. it doesn't have anything to with request context or not. Just that
> > doing DetachedCriteria.getExecutableCriteria(session) just won't work
> with
> > the shadow Session proxy because Hibernate tries to cast it to
> > SessionImplementor. Wonder if it could be fixed in tapestry-hibernate,
> > telling the proxy it needs to implement both Session and
> SessionImplementor.
> >
> > Kalle
> >
> >
> > On Wed, Feb 4, 2009 at 3:57 PM, Kalle Korhonen
> > <ka...@gmail.com>wrote:
> >
> >> I just hit the same problem "cannot be cast to ...SessionImplementor"
> while
> >> trying to use Hibernate session in a service that auto-populates some
> >> entries to the database at start-up (so obviously not in request
> context).
> >> Did anybody find a solution for this?
> >>
> >> Kalle
> >>
> >>
> >>
> >> On Wed, Jul 9, 2008 at 10:08 AM, Britske <gb...@gmail.com> wrote:
> >>
> >>>
> >>> Wow I love that. Somehow I mistakenly thought it didn't work that way,
> >>> thanks.
> >>>
> >>> As a related question :
> >>> is there a way to get the 'real' session instead of the proxy on a call
> to
> >>> getSession()
> >>>
> >>> The reason I'm asking is that in a lot of cases I want to use
> >>> (Hibernate's)
> >>> DetachedCriteria's, so I can make a criteria, pass that as a parameter
> to
> >>> a
> >>> repository and let the repository get the current session and create a
> >>> real
> >>> criteria. (For reasons of seperation)
> >>>
> >>> This is done through
> detachedCriteria.getExecutableCriteria(getSession());
> >>>
> >>> However this always gives a classCastException, like:
> >>> java.lang.ClassCastException: $Session_11b08fbaf1e cannot be cast to
> >>> org.hibernate.engine.SessionImplementor.
> >>>
> >>> for a related post (similar problem) see:
> >>>
> >>>
> http://www.nabble.com/Hivemind-creates-proxy-Hibernate-Session-td9845916.html
> >>>
> >>> Therefore I need the 'real' object.
> >>> diong getSession().getSessionFactory().getCurrentSession() would solve
> my
> >>> problem, since that would be both the session of the current thread and
> >>> the
> >>> real object, but (as described in method 2 of my post) the context
> >>> assigned
> >>> to be tapestry-hibernate isn't there when accessing the session in this
> >>> way.
> >>>
> >>> Any suggestions on how to solve this as well? Much apreciated!
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> Howard Lewis Ship wrote:
> >>> >
> >>> > If you are using tapestry-hibernate, the injectable Session service
> is
> >>> > a perthread proxy.  It can be shared across threads, but each method
> >>> > invocation on the proxy is redirected to a real per-thread Hibernate
> >>> > session.
> >>> >
> >>> > On Wed, Jul 9, 2008 at 9:27 AM, Britske <gb...@gmail.com> wrote:
> >>> >>
> >>> >> I found some partial references on the list, but nothing that really
> >>> >> answered
> >>> >> the question, so:
> >>> >> How can I get the current (per-thread) hibernate-session (as
> configured
> >>> >> through tapestry-hibernate) from a singleton custom tapestry
> service?
> >>> >>
> >>> >> For reference:
> >>> >> I have a MySingleton-class build as a tapestry service.
> >>> >> MySingleton.getSingleton().getCurrentSession() should give me the
> >>> current
> >>> >> session (thread-bound) as managed by tapestry-hibernate.
> >>> >> This would enable me to access the current session from any class
> (not
> >>> >> just
> >>> >> components or tapestry services)
> >>> >>
> >>> >>
> >>> >> I tried 3 methods, 2 of which don't work, and 1 I'm not certain
> >>> >>
> >>> >> Method 1:
> >>> >> build the MySingleton-class and inject Session at constructortime.
> >>> >>
> >>> >> Problem:  the hibernate session that is created on constructor-time
> >>> stays
> >>> >> assoaciated with MySingleton  (correct?). So this doesn't give a
> >>> >> session-per-thread.
> >>> >>
> >>> >>
> >>> >> Method 2:
> >>> >> build the MySingleton-class and inject HibernateSessionSource
> >>> >> getCurrentSession(){
> >>> >>   return
> >>> hibernateSessionSource.getSessionFactory().getCurrentSession();
> >>> >> }
> >>> >>
> >>> >> Problem:
> >>> >>
> >>> >> but this gives error:
> >>> >> org.hibernate.HibernateException: No CurrentSessionContext
> configured!
> >>> >> I think this happens because the way the session is accessed
> bypasses
> >>> the
> >>> >> tapestry-hibernate session-in-view filter (HibernateSessionManager)
> >>> which
> >>> >> takes care of providing the context.
> >>> >>
> >>> >> Is there any way to make getSessionFactory() aware of the
> >>> >> HibernateSessionManager? So the above works?
> >>> >>
> >>> >>
> >>> >> Method 3:
> >>> >> build the MySingleton-class and inject ProperyShadowBuilder  and
> >>> >> HibernateSessionManager
> >>> >>
> >>> >> I figured this calling hibernateSessionManager.getSession() would
> give
> >>> me
> >>> >> the needed context (which lacked from method 2) . The problem is
> that
> >>> >> HibernateSessionManager is not a singleton either.
> >>> >> I thought this could be bypassed by doing :
> >>> >>
> >>> >> getCurrentSession(){
> >>> >> return shadowBuilder.build(hibernateSessionManager, "session",
> >>> >> Session.class);
> >>> >> }
> >>> >>
> >>> >> However this still doens't ensure (I think) that
> >>> hibernateSessionManager
> >>> >> belongs to the current thread.
> >>> >>
> >>> >>
> >>> >> Can anyone shed some light on this? I would highly appreciate it!
> >>> >> Cheers,
> >>> >> britske
> >>> >>
> >>> >>
> >>> >> --
> >>> >> View this message in context:
> >>> >>
> >>>
> http://www.nabble.com/T5%3A-getting-current-hibernate-session-%28per-thread%29-from-singleton-service-tp18365296p18365296.html
> >>> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>> >>
> >>> >>
> >>> >>
> ---------------------------------------------------------------------
> >>> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>> >>
> >>> >>
> >>> >
> >>> >
> >>> >
> >>> > --
> >>> > Howard M. Lewis Ship
> >>> >
> >>> > Creator Apache Tapestry and Apache HiveMind
> >>> >
> >>> > ---------------------------------------------------------------------
> >>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>> > For additional commands, e-mail: users-help@tapestry.apache.org
> >>> >
> >>> >
> >>> >
> >>>
> >>> --
> >>> View this message in context:
> >>>
> http://www.nabble.com/T5%3A-getting-current-hibernate-session-%28per-thread%29-from-singleton-service-tp18365296p18367496.html
> >>> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>
> >>>
> >>
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator Apache Tapestry and Apache HiveMind
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T5: getting current hibernate session (per-thread) from singleton-service

Posted by Howard Lewis Ship <hl...@gmail.com>.
HibernateSessionManager.getSession()


On Wed, Feb 4, 2009 at 9:16 PM, Kalle Korhonen
<ka...@gmail.com> wrote:
> Noo.. it doesn't have anything to with request context or not. Just that
> doing DetachedCriteria.getExecutableCriteria(session) just won't work with
> the shadow Session proxy because Hibernate tries to cast it to
> SessionImplementor. Wonder if it could be fixed in tapestry-hibernate,
> telling the proxy it needs to implement both Session and SessionImplementor.
>
> Kalle
>
>
> On Wed, Feb 4, 2009 at 3:57 PM, Kalle Korhonen
> <ka...@gmail.com>wrote:
>
>> I just hit the same problem "cannot be cast to ...SessionImplementor" while
>> trying to use Hibernate session in a service that auto-populates some
>> entries to the database at start-up (so obviously not in request context).
>> Did anybody find a solution for this?
>>
>> Kalle
>>
>>
>>
>> On Wed, Jul 9, 2008 at 10:08 AM, Britske <gb...@gmail.com> wrote:
>>
>>>
>>> Wow I love that. Somehow I mistakenly thought it didn't work that way,
>>> thanks.
>>>
>>> As a related question :
>>> is there a way to get the 'real' session instead of the proxy on a call to
>>> getSession()
>>>
>>> The reason I'm asking is that in a lot of cases I want to use
>>> (Hibernate's)
>>> DetachedCriteria's, so I can make a criteria, pass that as a parameter to
>>> a
>>> repository and let the repository get the current session and create a
>>> real
>>> criteria. (For reasons of seperation)
>>>
>>> This is done through detachedCriteria.getExecutableCriteria(getSession());
>>>
>>> However this always gives a classCastException, like:
>>> java.lang.ClassCastException: $Session_11b08fbaf1e cannot be cast to
>>> org.hibernate.engine.SessionImplementor.
>>>
>>> for a related post (similar problem) see:
>>>
>>> http://www.nabble.com/Hivemind-creates-proxy-Hibernate-Session-td9845916.html
>>>
>>> Therefore I need the 'real' object.
>>> diong getSession().getSessionFactory().getCurrentSession() would solve my
>>> problem, since that would be both the session of the current thread and
>>> the
>>> real object, but (as described in method 2 of my post) the context
>>> assigned
>>> to be tapestry-hibernate isn't there when accessing the session in this
>>> way.
>>>
>>> Any suggestions on how to solve this as well? Much apreciated!
>>>
>>>
>>>
>>>
>>>
>>>
>>> Howard Lewis Ship wrote:
>>> >
>>> > If you are using tapestry-hibernate, the injectable Session service is
>>> > a perthread proxy.  It can be shared across threads, but each method
>>> > invocation on the proxy is redirected to a real per-thread Hibernate
>>> > session.
>>> >
>>> > On Wed, Jul 9, 2008 at 9:27 AM, Britske <gb...@gmail.com> wrote:
>>> >>
>>> >> I found some partial references on the list, but nothing that really
>>> >> answered
>>> >> the question, so:
>>> >> How can I get the current (per-thread) hibernate-session (as configured
>>> >> through tapestry-hibernate) from a singleton custom tapestry service?
>>> >>
>>> >> For reference:
>>> >> I have a MySingleton-class build as a tapestry service.
>>> >> MySingleton.getSingleton().getCurrentSession() should give me the
>>> current
>>> >> session (thread-bound) as managed by tapestry-hibernate.
>>> >> This would enable me to access the current session from any class (not
>>> >> just
>>> >> components or tapestry services)
>>> >>
>>> >>
>>> >> I tried 3 methods, 2 of which don't work, and 1 I'm not certain
>>> >>
>>> >> Method 1:
>>> >> build the MySingleton-class and inject Session at constructortime.
>>> >>
>>> >> Problem:  the hibernate session that is created on constructor-time
>>> stays
>>> >> assoaciated with MySingleton  (correct?). So this doesn't give a
>>> >> session-per-thread.
>>> >>
>>> >>
>>> >> Method 2:
>>> >> build the MySingleton-class and inject HibernateSessionSource
>>> >> getCurrentSession(){
>>> >>   return
>>> hibernateSessionSource.getSessionFactory().getCurrentSession();
>>> >> }
>>> >>
>>> >> Problem:
>>> >>
>>> >> but this gives error:
>>> >> org.hibernate.HibernateException: No CurrentSessionContext configured!
>>> >> I think this happens because the way the session is accessed bypasses
>>> the
>>> >> tapestry-hibernate session-in-view filter (HibernateSessionManager)
>>> which
>>> >> takes care of providing the context.
>>> >>
>>> >> Is there any way to make getSessionFactory() aware of the
>>> >> HibernateSessionManager? So the above works?
>>> >>
>>> >>
>>> >> Method 3:
>>> >> build the MySingleton-class and inject ProperyShadowBuilder  and
>>> >> HibernateSessionManager
>>> >>
>>> >> I figured this calling hibernateSessionManager.getSession() would give
>>> me
>>> >> the needed context (which lacked from method 2) . The problem is that
>>> >> HibernateSessionManager is not a singleton either.
>>> >> I thought this could be bypassed by doing :
>>> >>
>>> >> getCurrentSession(){
>>> >> return shadowBuilder.build(hibernateSessionManager, "session",
>>> >> Session.class);
>>> >> }
>>> >>
>>> >> However this still doens't ensure (I think) that
>>> hibernateSessionManager
>>> >> belongs to the current thread.
>>> >>
>>> >>
>>> >> Can anyone shed some light on this? I would highly appreciate it!
>>> >> Cheers,
>>> >> britske
>>> >>
>>> >>
>>> >> --
>>> >> View this message in context:
>>> >>
>>> http://www.nabble.com/T5%3A-getting-current-hibernate-session-%28per-thread%29-from-singleton-service-tp18365296p18365296.html
>>> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>> >>
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> >> For additional commands, e-mail: users-help@tapestry.apache.org
>>> >>
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Howard M. Lewis Ship
>>> >
>>> > Creator Apache Tapestry and Apache HiveMind
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> > For additional commands, e-mail: users-help@tapestry.apache.org
>>> >
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/T5%3A-getting-current-hibernate-session-%28per-thread%29-from-singleton-service-tp18365296p18367496.html
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: getting current hibernate session (per-thread) from singleton-service

Posted by Kalle Korhonen <ka...@gmail.com>.
Noo.. it doesn't have anything to with request context or not. Just that
doing DetachedCriteria.getExecutableCriteria(session) just won't work with
the shadow Session proxy because Hibernate tries to cast it to
SessionImplementor. Wonder if it could be fixed in tapestry-hibernate,
telling the proxy it needs to implement both Session and SessionImplementor.

Kalle


On Wed, Feb 4, 2009 at 3:57 PM, Kalle Korhonen
<ka...@gmail.com>wrote:

> I just hit the same problem "cannot be cast to ...SessionImplementor" while
> trying to use Hibernate session in a service that auto-populates some
> entries to the database at start-up (so obviously not in request context).
> Did anybody find a solution for this?
>
> Kalle
>
>
>
> On Wed, Jul 9, 2008 at 10:08 AM, Britske <gb...@gmail.com> wrote:
>
>>
>> Wow I love that. Somehow I mistakenly thought it didn't work that way,
>> thanks.
>>
>> As a related question :
>> is there a way to get the 'real' session instead of the proxy on a call to
>> getSession()
>>
>> The reason I'm asking is that in a lot of cases I want to use
>> (Hibernate's)
>> DetachedCriteria's, so I can make a criteria, pass that as a parameter to
>> a
>> repository and let the repository get the current session and create a
>> real
>> criteria. (For reasons of seperation)
>>
>> This is done through detachedCriteria.getExecutableCriteria(getSession());
>>
>> However this always gives a classCastException, like:
>> java.lang.ClassCastException: $Session_11b08fbaf1e cannot be cast to
>> org.hibernate.engine.SessionImplementor.
>>
>> for a related post (similar problem) see:
>>
>> http://www.nabble.com/Hivemind-creates-proxy-Hibernate-Session-td9845916.html
>>
>> Therefore I need the 'real' object.
>> diong getSession().getSessionFactory().getCurrentSession() would solve my
>> problem, since that would be both the session of the current thread and
>> the
>> real object, but (as described in method 2 of my post) the context
>> assigned
>> to be tapestry-hibernate isn't there when accessing the session in this
>> way.
>>
>> Any suggestions on how to solve this as well? Much apreciated!
>>
>>
>>
>>
>>
>>
>> Howard Lewis Ship wrote:
>> >
>> > If you are using tapestry-hibernate, the injectable Session service is
>> > a perthread proxy.  It can be shared across threads, but each method
>> > invocation on the proxy is redirected to a real per-thread Hibernate
>> > session.
>> >
>> > On Wed, Jul 9, 2008 at 9:27 AM, Britske <gb...@gmail.com> wrote:
>> >>
>> >> I found some partial references on the list, but nothing that really
>> >> answered
>> >> the question, so:
>> >> How can I get the current (per-thread) hibernate-session (as configured
>> >> through tapestry-hibernate) from a singleton custom tapestry service?
>> >>
>> >> For reference:
>> >> I have a MySingleton-class build as a tapestry service.
>> >> MySingleton.getSingleton().getCurrentSession() should give me the
>> current
>> >> session (thread-bound) as managed by tapestry-hibernate.
>> >> This would enable me to access the current session from any class (not
>> >> just
>> >> components or tapestry services)
>> >>
>> >>
>> >> I tried 3 methods, 2 of which don't work, and 1 I'm not certain
>> >>
>> >> Method 1:
>> >> build the MySingleton-class and inject Session at constructortime.
>> >>
>> >> Problem:  the hibernate session that is created on constructor-time
>> stays
>> >> assoaciated with MySingleton  (correct?). So this doesn't give a
>> >> session-per-thread.
>> >>
>> >>
>> >> Method 2:
>> >> build the MySingleton-class and inject HibernateSessionSource
>> >> getCurrentSession(){
>> >>   return
>> hibernateSessionSource.getSessionFactory().getCurrentSession();
>> >> }
>> >>
>> >> Problem:
>> >>
>> >> but this gives error:
>> >> org.hibernate.HibernateException: No CurrentSessionContext configured!
>> >> I think this happens because the way the session is accessed bypasses
>> the
>> >> tapestry-hibernate session-in-view filter (HibernateSessionManager)
>> which
>> >> takes care of providing the context.
>> >>
>> >> Is there any way to make getSessionFactory() aware of the
>> >> HibernateSessionManager? So the above works?
>> >>
>> >>
>> >> Method 3:
>> >> build the MySingleton-class and inject ProperyShadowBuilder  and
>> >> HibernateSessionManager
>> >>
>> >> I figured this calling hibernateSessionManager.getSession() would give
>> me
>> >> the needed context (which lacked from method 2) . The problem is that
>> >> HibernateSessionManager is not a singleton either.
>> >> I thought this could be bypassed by doing :
>> >>
>> >> getCurrentSession(){
>> >> return shadowBuilder.build(hibernateSessionManager, "session",
>> >> Session.class);
>> >> }
>> >>
>> >> However this still doens't ensure (I think) that
>> hibernateSessionManager
>> >> belongs to the current thread.
>> >>
>> >>
>> >> Can anyone shed some light on this? I would highly appreciate it!
>> >> Cheers,
>> >> britske
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/T5%3A-getting-current-hibernate-session-%28per-thread%29-from-singleton-service-tp18365296p18365296.html
>> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>
>> >>
>> >
>> >
>> >
>> > --
>> > Howard M. Lewis Ship
>> >
>> > Creator Apache Tapestry and Apache HiveMind
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/T5%3A-getting-current-hibernate-session-%28per-thread%29-from-singleton-service-tp18365296p18367496.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>