大家看下我的配置,我总感觉我的配置有些混乱,大家能不能给些精简的办法,还有,如果,我要在业务层实现事务管理,请问该怎么办?id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="mappingDirectoryLocations">
<list>
<value>/WEB-INF/mapping</value>
</list>
</property> <property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property> </bean> <bean id="transactionAttributeSource"
class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
<property name="properties">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="del*">PROPAGATION_REQUIRED</prop>
<prop key="query*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="transactionAttributeSource">
<ref bean="transactionAttributeSource" />
</property>
</bean>

解决方案 »

  1.   


    <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>   <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="configLocation"
    value="classpath:hibernate.cfg.xml">
    </property>
    </bean>
    <bean id="NoticeDAO" class="dao.NoticeDAO">
    <property name="sessionFactory">
    <ref bean="sessionFactory"></ref>
    </property>
    </bean>
    <bean id="transactionManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager">
       <property name="sessionFactory">
               <ref local="sessionFactory"/>
       </property>
    </bean>
      

  2.   

    @Transactional
    public class NoticeDAO以上为标注法实现事务