hibernate与ibatis整合,hibernate与jdbc整合
#------------ JDBC ------------ jdbc.driver=oracle.jdbc.driver.OracleDriver jdbc.url=jdbc:oracle:thin:@localhost:1521:orcl jdbc.username=scott jdbc.password=tgl #------------ Pools ------------ connection_pools.initial_pool_size=5 connection_pools.min_pool_size=5 connection_pools.max_pool_size=100 connection_pools.max_idle_time=600 connection_pools.acquire_increment=5 connection_pools.checkout_timeout=60000 #------------ hibernate ------------ hibernate.dialect=org.hibernate.dialect.Oracle10gDialect hibernate.hbm2ddl.auto=none hibernate.show_sql=true hibernate.format_sql=true hibernate.max_fetch_depth=3 hibernate.hibernate.jdbc.fetch_size=18 hibernate.jdbc.batch_size=10 #------------ hibernate cache------------ hibernate.cache.use_second_level_cache=true hibernate.cache.use_query_cache=false hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
hibernate用来简单增删改,ibatis的强项用来做批量修改,查询
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="${jdbc.driver}" /> <property name="jdbcUrl" value="${jdbc.url}" /> <property name="user" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="initialPoolSize" value="${connection_pools.initial_pool_size}" /> <property name="minPoolSize" value="${connection_pools.min_pool_size}" /> <property name="maxPoolSize" value="${connection_pools.max_pool_size}" /> <property name="maxIdleTime" value="${connection_pools.max_idle_time}" /> <property name="acquireIncrement" value="${connection_pools.acquire_increment}" /> <property name="checkoutTimeout" value="${connection_pools.checkout_timeout}" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="packagesToScan" value="com.cb.entity."/> <property name="mappingDirectoryLocations"> <value>classpath:hibernate-mapping</value> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.format_sql">${hibernate.format_sql}</prop> <prop key="hibernate.max_fetch_depth">${hibernate.max_fetch_depth}</prop> <prop key="hibernate.hibernate.jdbc.fetch_size">${hibernate.hibernate.jdbc.fetch_size}</prop> <prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop> </props> </property> <!-- 让事务知道数据源,hibernate与jdbc(Ibatis)使用同一个连接和事务--> <property name="useTransactionAwareDataSource" value="true"></property> </bean> <!--ibatis--> <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="configLocation"> <value>classpath:sqlMap/sqlMapConfig.xml</value> </property> <property name="mappingLocations"> <value>classpath:sqlMap/**/*_sql.xml</value> </property> </bean> <bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate"> <property name="sqlMapClient" ref="sqlMapClient"></property> </bean> <!--hibernate与jdbc(Ibatis)整合事务hibernate与jdbc(Ibatis)--> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <!--事务模板作用(编程式事务)如定时任务 --> <bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate"> <property name="transactionManager" ref="txManager" /> <property name="isolationLevelName" value="ISOLATION_DEFAULT" /> <property name="propagationBehaviorName" value="PROPAGATION_REQUIRED" /> <property name="timeout" value="30" /> </bean> <!--事务注解--> <tx:annotation-driven transaction-manager="txManager" />
相关推荐
ASoc 2020-11-14
Andrea0 2020-09-18
Cherishyuu 2020-08-19
dongtiandeyu 2020-08-18
CoderYYN 2020-08-16
大黑牛 2020-08-15
Dullonjiang 2020-08-11
gaozhennan 2020-08-03
mcvsyy 2020-08-02
zbcaicai 2020-07-29
AscaryBird 2020-07-27
liulin0 2020-07-26
ldcwang 2020-07-26
helloxusir 2020-07-25
娜娜 2020-07-20
pengpengflyjhp 2020-07-19
点滴技术生活 2020-07-19
人可 2020-07-18
chenjiazhu 2020-07-08