hibernate3.05
hibernate-annotations-3.0beta2
spring1.21
几个配置文件如下:
spring-database.xml(这个文件基本不变,有新的dao在底下加入一行即可。














































<bean id="mitService" class="org.steeven.TestServiceImpl"></bean>



hibernate.cfg.xml



















上面两个就是配置文件的全部了。下面看看代码:
TestDao.java(注意,就是个普通的dao,事务控制由调用者标注)


































































TestServiceImpl.java(这个类也是从spring中取得,关键就在@Transactional标记)














现在很清爽了,所有的事务控制只需要加几个@Transaction标记。感谢hibernate+spring
另外,hibernate还提供了基于标记的参数校验,请参考下面文档:
参考资源:
spring1.21自带smaples/jpetstore
http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/
初次玩spring&hibernate,请多指教!