Re: spring hibernate injection
On Mar 2, 4:11 pm, Aeris <ae...@imirhil.fr> wrote:
euneve...@yahoo.co.uk wrote:
I don't see any =ABdetailsService=BB in your Spring configuration. So=85
In your config file, your real DAO is a proxy of your class, managed by
Spring through CGLIB, so your DAO type in your service must not be MyDAO
directly but a dynamic type build at runtime by CGLIB, which is impossibl=
e
to manage with Spring (all type must be known at compile time, not at
runtime).
If you want 3tiers architecture (DOM/DAO/Service), you have to handle
=ABnative=BB class (not proxified):
public class MyDAO {}
public class MyService {
private MyDAO dao;
public void setDAO(MyDAO dao) { this.dao = dao; }
}
<bean id="myDao" class="MyDAO" />
<bean id="myService" class="MyService">
<property name="dao" ref="myDao" />
</bean>
--
Aeris
That's good and I have no wish to have a proxified class.
But how can I have a POJO DAO like in Apress "beginning hibernate"
that doesn't need to worry about sessions ie just
Session session = this.sessionFactory.getCurrentSession();
and allows rendering to JSP and no need to start or commit
transactions.
I will be using this in a read-only environment and I want to avoid
worrying about connections/sessions/transactions.
Also this code would be used as a template for future java based
reports.
If I have to use HibernateDaoSupport I will, I just thought the above
way was recommended.
Cheers.