Thanks Mike!
Michael Horwitz wrote:
Hi Richard,
If you are set on using Hibernate to manage your transactions, then
you should inject the SessionFactory into your controller. The session
factory is created by the Spring LocalSessionFactoryBean - note that
all classes ending in FactoryBean are bean factories that create an
instance of the underlying class and place it in the Spring
application context (in this case org.hibernate.SessionFactory). From
there you can call getCurrentSession() to obtain the current session,
and from there access the transaction methods you need.
Mike.
On 7/17/07, *Richard Reyes* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Hi Mike, All,
Thanks for the response.
I will look into the spring aop approach, but as an interim
solution I
am not sure I can inject the hibernate session into the controller? I
tried injecting...
org.springframework.orm.hibernate3.LocalSessionFactoryBean
or
org.springframework.orm.hibernate3.HibernateTransactionManager
but theres no way to begin or commit transaction from there.
Please advise...
Thanks.
Richard
Michael Horwitz wrote:
> Not sure as to the exact question here. All transaction handling in
> AppFuse 1.9.4 is done through Spring AOP transaction
interceptors. For
> details look in the applicationContext-service.xml file. Full
> documentation for Spring AOP transactions can be found here:
>
http://static.springframework.org/spring/docs/2.0.x/reference/transaction.html
>
> By default AppFuse is configured to start a transaction when the
> calling thread enters any method on a Manager class and close the
> corresponding transaction when the calling thread returns from the
> method. The OpenSessionInView filter takes care of opening and
closing
> the session so that the session stays open to instantiate lazy
> collections accessed in JSP pages.
>
> You can access the current session in your controller if you really
> want to - just use sessionFactory.getCurrentSession() and pass the
> sessionFactory into your controller using Spring dependency
injection.
> You should not need to change the DAO classes to do this.
>
> Mike.
>
> On 7/17/07, *Richard Reyes* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
> <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>>
wrote:
>
> Hi All,
>
> We are using Appfuse 1.9.4 spring mvc version. May I ask the
best
> way to
> enforce starting a transaction?
>
> Business logic is at the formscontroller level right but the
hibernate
> session is accessible only in the dao layer.
>
> Is it alright to provide a getter on a certain dao
implementation and
> then use the session in the controller level if only to issue a
> session.beginTransaction command?
>
> TIA!
>
> Regards,
> Richard
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
> <mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
> For additional commands, e-mail:
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
> <mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]