<
bean
id
="sessionFactory"
class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
>
<
property
name
="dataSource"
>
<
ref
local
="dataSource"
/>
</
property
>
<!--
bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/
-->
<
bean
id
="transactionManager"
class
="org.springframework.orm.hibernate3.HibernateTransactionManager"
>
<
property
name
="sessionFactory"
>
<
ref
local
="sessionFactory"
/>
</
property
>
</
bean
>
<!--
Hibernate Transaction Interceptor Definition
-->
<
bean
id
="hibernateTransactionInterceptor"
class
="org.springframework.transaction.interceptor.TransactionInterceptor"
parent
="transactionIntercetorTemplate"
>
<
property
name
="transactionManager"
>
<
bean
id
="hibernateTransactionManager"
class
="org.springframework.orm.hibernate3.HibernateTransactionManager"
>
<
property
name
="sessionFactory"
>
<
ref
bean
="sessionFactory"
/>
</
property
>
</
bean
>
</
property
>
</
bean
>
<!--
Transction Intercetor's Template
-->
<
bean
id
="transactionIntercetorTemplate"
abstract
="true"
>
<
property
name
="transactionAttributes"
>
<
props
>
<
prop
key
="get*"
>
PROPAGATION_REQUIRED,readOnly
</
prop
>
<
prop
key
="is*"
>
PROPAGATION_REQUIRED,readOnly
</
prop
>
<
prop
key
="check*"
>
PROPAGATION_REQUIRED,readOnly
</
prop
>
<
prop
key
="insert*"
>
PROPAGATION_REQUIRED
</
prop
>
<
prop
key
="update*"
>
PROPAGATION_REQUIRED
</
prop
>
<
prop
key
="delete*"
>
PROPAGATION_REQUIRED,-BussException
</
prop
>
<
prop
key
="*"
>
PROPAGATION_REQUIRED
</
prop
>
</
props
>
</
property
>
</
bean
>
<!--
定义自动代理生成器
-->
<
bean
id
="autoProxyCreator"
class
="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"
>
<
property
name
="interceptorNames"
>
<
list
>
<
idref
bean
="hibernateTransactionInterceptor"
/>
<
idref
bean
="jdbcTransactionInterceptor"
/>
</
list
>
</
property
>
<
property
name
="beanNames"
>
<
value
>
*Service
</
value
>
<!--
list>
<idref bean="bookService" />
</list
-->
<!--
添加Service bean
-->
</
property
>
</
bean
>
<
bean
id
="hibernateDaoTemplate"
abstract
="true"
>
<
property
name
="sessionFactory"
>
<
ref
bean
="sessionFactory"
/>
</
property
>
</
bean
>
<!--
Dao 定义
-->
<
bean
id
="imageDao"
class
="com.fbyssssite.dao.ImageDao"
parent
="hibernateDaoTemplate"
/>
<
bean
id
="imageFolderDao"
class
="com.fbyssssite.dao.ImageFolderDao"
parent
="hibernateDaoTemplate"
/>
<!--
Service 定义
-->
<
bean
id
="imageService"
class
="com.fbyssssite.bo.ImageService"
autowire
="byName"
>
<
property
name
="dao"
ref
="imageDao"
></
property
>
</
bean
>
<
bean
id
="imageFolderService"
class
="com.fbyssssite.bo.ImageFolderService"
autowire
="byName"
>
<
property
name
="dao"
ref
="imageFolderDao"
></
property
>
</
bean
>
Spring事务配置
最新推荐文章于 2024-08-08 15:53:37 发布