Popular question on Hibernate Synchronizer forum involves using it with Spring. Here's one way:
The following steps assume you have already installed the Hibernate Synchronizer in Eclipse:
1) Update the Hibernate Synchronizer to use a custom base root (
Click Here for Source Code)
From Menu bar: Project->Properties->Hibernate Synchronizer->Data Access Objects tab->Check "I would like to use a custom root" and enter full path to the SpringBaseRootDAO
2) Update the Hibernate Synchronizer to use a custom Exception class
Same location as above. Enter "org.springframework.dao.DataAccessException" for DAO Exception input box
3) Update Base DAO Snippets
a) On Eclipse Menu bar, click Window->Preferences
b) Click Hibernate Synchronizer on left panel
c) Click Snippets
d) Expand Base DAO
e) Replace Action Methods with
thisf) Replace Finder Methods with
thisg) Replace Imports with
thish) Replace Required Methods with
this(I removed JRE 1.5 specific content from snippets)
4) Configure your generated DAO(s) to inject a
LocalSessionFactory for HibernateTemplate's "sessionFactory" property (SpringBaseRootDAO extends
HibernateTemplate). For example, an entry in the applicationContext.xml might look like:
<bean id="usersDataAccessObject" class="com.xyz.data.dao.UsersDAO">
<property name="sessionFactory">
<ref local="mySessionFactory"/>
</property>
</bean>
Of course, the above example assumes you have "mySessionFactory" bean defined.
Hope this helps. Comments welcome.