Announcement Announcement Module
No announcement yet.
Initialisation problems with a DaoSupport bean Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Initialisation problems with a DaoSupport bean

    Hi all,

    I'm having problems with my DAO bean extended from HibernateDaoSupport. I need to do some initialisation when the bean is created, however if I try to call getHibernateTemplate() from the constructor I find it null.. I assume even though I've used constructor injection and wait until other dependencies have been satisfied before calling hibernate the autowiring(?) of the sessionfactory won't happen until after the constructor has completed..? In any case changing my bean def to depend-on the sessionFactory didnt do much.

    So I need to do this initialisation after the constructor, but before the bean is used in anger. Reluctantly (deepening my swing dependencies) I've been looking at making my dao implement InitializingBean which'll let me do initialisation in the afterPropertiesSet method -- but much to my horror I find DaoSupport (extended by my dao) already implements InitializingBean and marks its afterPropertiesSet final to boot.. Is there another way to handle this kind of initilasation against the hibernate backend..?

    - Richard
    Last edited by osbald; Jan 11th, 2006, 11:23 AM.

  • #2
    Should have spent more time looking at the code rather than asking questions.. I notice that DaoSupport calls a protected extension point daoInit() which I can override in my dao. Spring black-magic, but it'll do the job.

    Now I'm having problems with HibernateTemplate.iterate();; which gives me back "JDBCConnectionException: could not get next iterator result" that in turn seems to stem from an underlying postgres "SQL Error: 0, SQLState: 08003 This ResultSet is closed.". So I guess the ResultSet is automatically closed after the call to HibernateTemplate.iterate() which begs the question how are you supposed to get any results from the returned iterator?

    Normally I suspect this wouldn't be an issue as we're using the opensessioninview filter to hold the session open while any jsp views are rendered, but in this case HibernateTemplate is being called via Springs afterPropertiesSet() .i.e. outside of the filters scope..?
    Last edited by osbald; Jan 11th, 2006, 11:28 AM.