spring 2.5+hibernate 3.0整合
hibernate3.0配置文件和spring2.5.6配置文件都放在src目录下,
spring配置文件如下配置
<tx:annotation-driven transaction-manager="txManager"/> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <bean id="hbmlist" class="java.util.ArrayList"> <constructor-arg> <list> <value>/conf/model/User.hbm.xml</value> <value>/conf/model/DictItem.hbm.xml</value> </list> </constructor-arg> </bean> <bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="properties"> <props> <prop key="hibernate.dialect">${mysql.hibernate.dialect}</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.format_sql">true</prop> <!-- <prop key="hibernate.cache.use_second_level_cache">true</prop> <prop key="hibernate.cache.use_query_cache">true</prop> <prop key="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.EhCacheRegionFactory</prop> --> <!-- <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop> <prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup</prop> <prop key="hibernate.query.substitutions" >true</prop> <prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop> --> <!-- <prop key="hibernate.hbm2ddl.auto">update</prop> --> <!-- <prop key="hibernate.cache.use_query_cache">true</prop>--> <!-- <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>--> </props> </property> </bean> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:/conf/dbusers.properties</value> </list> </property> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" > <value>${mysql.driverName}</value> </property> <property name="url"> <value>${mysql.url}</value> </property> <property name="username"> <value>${mysql.user}</value> </property> <property name="password"> <value>${mysql.password}</value> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="mappingResources" ref="hbmlist"/> <property name="hibernateProperties" ref="hibernateProperties"/> </bean>
2、所有dao类都继承org.springframework.orm.hibernate3.support.HibernateDaoSupport
相关推荐
yupi0 2020-10-10
spring 2020-08-18
编程点滴 2020-07-29
幸运小侯子 2020-07-05
itjavashuai 2020-07-04
qingjiuquan 2020-06-29
shushan 2020-06-25
小鱿鱼 2020-06-22
咻pur慢 2020-06-18
melonjj 2020-06-17
qingjiuquan 2020-06-13
neweastsun 2020-06-05
小鱿鱼 2020-06-05
mxcsdn 2020-05-31
吾日五省我身 2020-05-27
牧场SZShepherd 2020-05-27
sweetgirl0 2020-05-14