Please Enable JavaScript!
Gon[ Enable JavaScript ]

spring 에서 Hibernate 트랜잭션 설정과 sessionFactory 설정법

자바(JAVA)
반응형
application-jdbc.xml

<!-- Hibernate Framework Session Factory 등록 -->

<bean id="sessionFactory"

       class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

    <property name="dataSource" ref="dataSource" />

    <property name="mappingResources">

        <list>

           <value>gon/front/board/model/TbBoard.hbm.xml</value>

        </list>

    </property>

    <property name="hibernateProperties">

        <props>

        <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>

        <prop key="hibernate.hbm2ddl.auto">update</prop>

        </props>

    </property>

</bean>

 

<!-- Transaction Manager 설정하는 부분  -->

<bean id="transactionHibernateManager"

       class="org.springframework.orm.hibernate3.HibernateTransactionManager">

    <property name="sessionFactory" ref="sessionFactory"/>

</bean>

 

<!-- Proxy FactoryBean -->

<bean id="txProxyTemplate" abstract="true"

    class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">

    <property name="transactionManager" ref="transactionHibernateManager"/>

    <property name="transactionAttributes">

        <props>

        <prop key="insert*">PROPAGATION_REQUIRED</prop>

        <prop key="update*">PROPAGATION_REQUIRED</prop>

        <prop key="delete*">PROPAGATION_REQUIRED</prop>

        <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>

        </props>

    </property>

</bean>

application-board.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

  xmlns:aop="http://www.springframework.org/schema/aop"

  xsi:schemaLocation="http://www.springframework.org/schema/beans  

     http://www.springframework.org/schema/beans/spring-beans-2.0.xsd       

     http://www.springframework.org/schema/aop        

     http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

<bean id="communityDAOHibernate" class="gon.front.community.dao.CommunityDAOHibernate">

        <property name="sessionFactory" ref="sessionFactory"/>

</bean>

 

<bean id="communityServiceTarget" class="gon.front.community.service.CommunityService">

        <property name="communityDAOHibernate" ref="communityDAOHibernate"/>

</bean>

 

<bean id="communityService" parent="txProxyTemplate">

        <property name="target" ref="communityServiceTarget" />

</bean>

       

</beans>



반응형
Posted by 녹두장군1
,