My DAO's are going to extend the HibernateDaoSupport
class that spring provides.
Now I need to:
- setup my database connection in web.xml
- Tell spring I am using annotations for hibernate mapping?
- wire the session to the HibernateDaoSupport object.
The doc's show a sample xml:
<beans>
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
<property name="url" value="jdbc:hsqldb:hsql://localhost:9001"/>
<property name="username" value="sa"/>
<property name="password" value=""/>
</bean>
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="myDataSource"/>
<property name="mappingResources">
<list>
<value>product.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.HSQLDialect
</value>
</property>
</bean>
</beans>
So the 'mydatasource' configures the connection to the database, and the mySessionFactory sets up the session.
What I am confused with is, where in the code are these beans being used?
I want to create a GenericDaoImpl
that extendsHibernateDaoSupport
. I will then create EntityDaoImpl
that extend GenericDaoImpl.
Just confused as to where 'mydatasource' and 'mysessionFactory' are used internally. Shouldn't they both be properties to HibernateDaoSupport
?