Rukas - Oh, My Blog!

友情链接

最新评论

Using Hibernate Synchronizer 3 with Spring and Hibernate 3

http://www.supergloo.com/tmblog/2005/11/using-hibernate-synchronizer-3-with.html

Thursday, November 10, 2005

Using Hibernate Synchronizer 3 with Spring and Hibernate 3

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 this
f) Replace Finder Methods with this
g) Replace Imports with this
h) 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.

posted on 2005-11-23 21:35 Rukas - Oh, My Blog! 阅读(934) 评论(1)  编辑 收藏 引用 所属分类: Hibernate

评论

# re: Using Hibernate Synchronizer 3 with Spring and Hibernate 3 2008-01-07 23:07 sdfsdf

sdfsd  回复  更多评论   

只有注册用户登录后才能发表评论。