I used to have a getter/setter for sessionFactory in the base class my DAOs extended from (which extended from HibernateDaoSupport). To get the same thing to work with annotations and Spring 2.5 I had to use constructor injection. like:
This isn't really a problem, but I used to like making some of my classes autowired by default, like:Code:package whitney.repository.dao; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import org.springframework.stereotype.Repository; import whitney.entity.Entry; @Repository public class EntryDao extends HibernateDaoSupport{ @Autowired public EntryDao(SessionFactory sessionFactory){ super.setSessionFactory(sessionFactory); } public void save(Entry entry){ this.getHibernateTemplate().save(entry); } }
I guess this just isn't possible any more if I want to use the new spring 2.5 annotations?Code:<bean id="blah" class="foo.Blah" autowired="byName"/>


Reply With Quote