<beans>
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:resources/jdbc.properties</value>
</property>
</bean> <!-- Choose the dialect that matches your "dataSource" definition -->
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>${datasource.driverClassName}</value>
</property>
<property name="url">
<value>${datasource.url}</value>
</property>
<property name="username">
<value>${datasource.username}</value>
</property>
<property name="password">
<value>${datasource.password}</value>
</property>
<property name="maxActive">
<value>${datasource.maxActive}</value>
</property>
<property name="maxIdle">
<value>${datasource.maxIdle}</value>
</property>
<property name="maxWait">
<value>${datasource.maxWait}</value>
</property>
<property name="defaultAutoCommit">
<value>${datasource.defaultAutoCommit}</value>
</property>
</bean> <bean id="mySessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="dataSource"><ref local="myDataSource"/></property>
<property name="mappingResources">
<list>
<!--value>com/philwong/mstd/common/bean/CtrTabledictBean.hbm.xml</value-->
<value>test/bean/AuditProc.hbm.xml</value>
<value>test/bean/AuditBill.hbm.xml</value>
<value>test/bean/AuditBill.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
</props>
</property>
</bean>
<bean id="myTransactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory"><ref local="mySessionFactory" /></property>
</bean> <bean id="myTransactionProxyFactoryBean" lazy-init="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="myTransactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean> <bean id="mySendFormBizProxy" parent="myTransactionProxyFactoryBean">
<property name="target"><ref local="mySendFormBiz" /></property>
</bean> <bean id="mySendFormBiz" class="test.util.imp.SendFormBiz">
<property name="sendformdao">
<ref local="mySendFormDao"/>
</property>
</bean> <bean id="mySendFormDao" class="test.util.imp.SendFormDao">
<property name="sessionFactory">
<ref local="mySessionFactory"/>
</property>
</bean>
</beans>
public class SendFormDao extends HibernateDaoSupport implements ISendFormDao{ public List searchAuditBill(String lsh) {
String hql = "from AuditBill auditbill where auditbill.lsh = '"+lsh+"'";
return getHibernateTemplate().find(hql);
}
public List searchAuditBill(String shbillLsh) {
String hql = "from AuditBill auditbill where auditbill.shbillLsh = '"+shbillLsh+"'";
return getHibernateTemplate().find(hql);
}
public void saveAuditProc(AuditProc auditproc)
{
this.getHibernateTemplate().save(auditproc);
}
public void saveAuditBill(AuditBill auditbill)
{
this.getHibernateTemplate().save(auditbill);
}
public void saveAuditBill(AuditBill auditbill)
{
this.getHibernateTemplate().save(auditbill);
}
}
public class SendFormBiz implements ISendFormBiz{ private ISendFormDao sendformdao; public ISendFormDao getSendformdao() {
return sendformdao;
} public void setSendformdao(ISendFormDao sendformdao) {
this.sendformdao = sendformdao;
}
public void saveSendForm(AuditBill auditbill,AuditProc auditproc)
{
this.getSendformdao().saveAuditBill(auditbill);
this.getSendformdao().saveAuditProc(auditproc);
}
public List searchQuHuiSendAuditForm(String currprolsh)
{
return this.getSendformdao().searchAuditBill(currprolsh);
}
}事务是控制到SendFormBiz类中的方法,我想知道是不是saveSendForm方法在调用之前开始事务,在saveSendForm方法调用结束以后提交事务
而searchQuHuiSendAuditForm方法是不是不控制事务的??因为是受到配置文件中
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
的设置,不知道的我理解是否正确?
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:resources/jdbc.properties</value>
</property>
</bean> <!-- Choose the dialect that matches your "dataSource" definition -->
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>${datasource.driverClassName}</value>
</property>
<property name="url">
<value>${datasource.url}</value>
</property>
<property name="username">
<value>${datasource.username}</value>
</property>
<property name="password">
<value>${datasource.password}</value>
</property>
<property name="maxActive">
<value>${datasource.maxActive}</value>
</property>
<property name="maxIdle">
<value>${datasource.maxIdle}</value>
</property>
<property name="maxWait">
<value>${datasource.maxWait}</value>
</property>
<property name="defaultAutoCommit">
<value>${datasource.defaultAutoCommit}</value>
</property>
</bean> <bean id="mySessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="dataSource"><ref local="myDataSource"/></property>
<property name="mappingResources">
<list>
<!--value>com/philwong/mstd/common/bean/CtrTabledictBean.hbm.xml</value-->
<value>test/bean/AuditProc.hbm.xml</value>
<value>test/bean/AuditBill.hbm.xml</value>
<value>test/bean/AuditBill.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
</props>
</property>
</bean>
<bean id="myTransactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory"><ref local="mySessionFactory" /></property>
</bean> <bean id="myTransactionProxyFactoryBean" lazy-init="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="myTransactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean> <bean id="mySendFormBizProxy" parent="myTransactionProxyFactoryBean">
<property name="target"><ref local="mySendFormBiz" /></property>
</bean> <bean id="mySendFormBiz" class="test.util.imp.SendFormBiz">
<property name="sendformdao">
<ref local="mySendFormDao"/>
</property>
</bean> <bean id="mySendFormDao" class="test.util.imp.SendFormDao">
<property name="sessionFactory">
<ref local="mySessionFactory"/>
</property>
</bean>
</beans>
public class SendFormDao extends HibernateDaoSupport implements ISendFormDao{ public List searchAuditBill(String lsh) {
String hql = "from AuditBill auditbill where auditbill.lsh = '"+lsh+"'";
return getHibernateTemplate().find(hql);
}
public List searchAuditBill(String shbillLsh) {
String hql = "from AuditBill auditbill where auditbill.shbillLsh = '"+shbillLsh+"'";
return getHibernateTemplate().find(hql);
}
public void saveAuditProc(AuditProc auditproc)
{
this.getHibernateTemplate().save(auditproc);
}
public void saveAuditBill(AuditBill auditbill)
{
this.getHibernateTemplate().save(auditbill);
}
public void saveAuditBill(AuditBill auditbill)
{
this.getHibernateTemplate().save(auditbill);
}
}
public class SendFormBiz implements ISendFormBiz{ private ISendFormDao sendformdao; public ISendFormDao getSendformdao() {
return sendformdao;
} public void setSendformdao(ISendFormDao sendformdao) {
this.sendformdao = sendformdao;
}
public void saveSendForm(AuditBill auditbill,AuditProc auditproc)
{
this.getSendformdao().saveAuditBill(auditbill);
this.getSendformdao().saveAuditProc(auditproc);
}
public List searchQuHuiSendAuditForm(String currprolsh)
{
return this.getSendformdao().searchAuditBill(currprolsh);
}
}事务是控制到SendFormBiz类中的方法,我想知道是不是saveSendForm方法在调用之前开始事务,在saveSendForm方法调用结束以后提交事务
而searchQuHuiSendAuditForm方法是不是不控制事务的??因为是受到配置文件中
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
的设置,不知道的我理解是否正确?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货