华硕x540up内存条卡槽在哪55bq有mxm槽吗?

Spring 配置 事务的几种方式 - java小强 - ITeye技术网站
博客分类:
Spring配置文件中关于事务配置总是由三个组成部分,DataSource、TransactionManager和代理机制这三部分,无论是那种配置方法,一般变化的只是代理机制这块!
首先我创建了两个类,一个接口一个实现:
package com.
public interface UserDao {
public void getUser();
package com.dao.
import org.springframework.orm.hibernate3.support.HibernateDaoS
import com.dao.UserD
public class UserDaoImpl extends HibernateDaoSupport implements UserDao {
public void getUser(){
第一种:每个Bean都有一个代理:
&?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"
xmlns:tx="http://www.springframework.org/schema/tx"
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
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"&
&!-- 数据源 --&
&bean id="dataSource"
class="mons.dbcp.BasicDataSource"
destroy-method="close"&
&property name="driverClassName" value="com.mysql.jdbc.Driver" /&
&property name="url"
value="jdbc:mysql://192.168.0.244:3306/test?useUnicode=true&characterEncoding=UTF-8" /&
&property name="username" value="root" /&
&property name="password" value="root" /&
&!-- 连接池启动时的初始值 --&
&property name="initialSize" value="10" /&
&!-- 连接池的最大值 --&
&property name="maxActive" value="10" /&
&!-- 最大空闲值.当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 --&
&property name="maxIdle" value="20" /&
最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请 --&
&property name="minIdle" value="10" /&
&property name="defaultAutoCommit" value="true" /&
&!-- 会话工厂 --&
&bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&
&property name="dataSource" ref="dataSource" /&
&property name="mappingLocations"&
&value&classpath:/com/nms/entity/**/*.hbm.xml&/value&
&/property&
&property name="hibernateProperties"&
&prop key="hibernate.dialect"&
org.hibernate.dialect.MySQL5Dialect
&prop key="hibernate.show_sql"&true&/prop&
&prop key="hibernate.format_sql"&true&/prop&
&/property&
&!-- 定义事务管理器 --&
&bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"&
&property name="sessionFactory" ref="sessionFactory" /&
&!-- 配置服务层 --&
&bean id="userDaoAgency" class="com.dao.impl.UserDaoImpl"&
&property name="sessionFactory" ref="sessionFactory" /&
&bean id="userDao"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"&
&!-- 配置事务管理器 --&
&property name="transactionManager" ref="transactionManager" /&
&property name="target" ref="userDaoAgency" /&
&property name="proxyInterfaces" value="com.dao.UserDao" /&
&!-- 配置事务属性 --&
&property name="transactionAttributes"&
&prop key="*"&PROPAGATION_REQUIRED&/prop&
&/property&
第二种:所有Bean共享一个代理:
&?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"
xmlns:tx="http://www.springframework.org/schema/tx"
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
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"&
&!-- 数据源 --&
&bean id="dataSource"
class="mons.dbcp.BasicDataSource"
destroy-method="close"&
&property name="driverClassName" value="com.mysql.jdbc.Driver" /&
&property name="url"
value="jdbc:mysql://192.168.0.244:3306/test?useUnicode=true&characterEncoding=UTF-8" /&
&property name="username" value="root" /&
&property name="password" value="root" /&
&!-- 连接池启动时的初始值 --&
&property name="initialSize" value="10" /&
&!-- 连接池的最大值 --&
&property name="maxActive" value="10" /&
&!-- 最大空闲值.当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 --&
&property name="maxIdle" value="20" /&
最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请 --&
&property name="minIdle" value="10" /&
&property name="defaultAutoCommit" value="true" /&
&!-- 会话工厂 --&
&bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&
&property name="dataSource" ref="dataSource" /&
&property name="mappingLocations"&
&value&classpath:/com/nms/entity/**/*.hbm.xml&/value&
&/property&
&property name="hibernateProperties"&
&prop key="hibernate.dialect"&
org.hibernate.dialect.MySQL5Dialect
&prop key="hibernate.show_sql"&true&/prop&
&prop key="hibernate.format_sql"&true&/prop&
&/property&
&!-- 定义事务管理器 --&
&bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"&
&property name="sessionFactory" ref="sessionFactory" /&
&!-- 定义事务 --&
&bean id="base"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
lazy-init="true" abstract="true"&
&!-- 配置事务管理器 --&
&property name="transactionManager" ref="transactionManager" /&
&!-- 配置事务属性 --&
&property name="transactionAttributes"&
&prop key="*"&PROPAGATION_REQUIRED&/prop&
&/property&
&!-- 配置服务层 --&
&bean id="userDao"
class="com.dao.impl.UserDaoImpl"&
&property name="sessionFactory" ref="sessionFactory" /&
&!-- 代理对象 --&
&bean id="userDaoAgency" parent="base"&
&property name="target" ref="userDao" /&
第三种:拦截器:
&?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"
xmlns:tx="http://www.springframework.org/schema/tx"
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
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"&
&!-- 数据源 --&
&bean id="dataSource"
class="mons.dbcp.BasicDataSource"
destroy-method="close"&
&property name="driverClassName" value="com.mysql.jdbc.Driver" /&
&property name="url"
value="jdbc:mysql://192.168.0.244:3306/test?useUnicode=true&characterEncoding=UTF-8" /&
&property name="username" value="root" /&
&property name="password" value="root" /&
&!-- 连接池启动时的初始值 --&
&property name="initialSize" value="10" /&
&!-- 连接池的最大值 --&
&property name="maxActive" value="10" /&
&!-- 最大空闲值.当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 --&
&property name="maxIdle" value="20" /&
最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请 --&
&property name="minIdle" value="10" /&
&property name="defaultAutoCommit" value="true" /&
&!-- 会话工厂 --&
&bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&
&property name="dataSource" ref="dataSource" /&
&property name="mappingLocations"&
&value&classpath:/com/nms/entity/**/*.hbm.xml&/value&
&/property&
&property name="hibernateProperties"&
&prop key="hibernate.dialect"&
org.hibernate.dialect.MySQL5Dialect
&prop key="hibernate.show_sql"&true&/prop&
&prop key="hibernate.format_sql"&true&/prop&
&/property&
&!-- 定义事务管理器(声明式的事务) --&
&bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"&
&property name="sessionFactory" ref="sessionFactory" /&
&!-- 定义事务 --&
&bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor"&
&property name="transactionManager" ref="transactionManager" /&
&!-- 配置事务属性 --&
&property name="transactionAttributes"&
&prop key="*"&PROPAGATION_REQUIRED&/prop&
&/property&
&bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"&
&property name="beanNames"&
&value&*DaoImpl&/value&
&/property&
&property name="interceptorNames"&
&value&transactionInterceptor&/value&
&/property&
&!-- 配置服务层 --&
&bean id="userDaoAgency" class="com.dao.impl.UserDaoImpl"&
&property name="sessionFactory" ref="sessionFactory" /&
第四种:使用tx标签配置的拦截器:
&?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"&
&!-- 数据源 --&
&bean id="dataSource"
class="mons.dbcp.BasicDataSource"
destroy-method="close"&
&property name="driverClassName" value="com.mysql.jdbc.Driver" /&
&property name="url"
value="jdbc:mysql://192.168.0.244:3306/test?useUnicode=true&characterEncoding=UTF-8" /&
&property name="username" value="root" /&
&property name="password" value="root" /&
&!-- 连接池启动时的初始值 --&
&property name="initialSize" value="10" /&
&!-- 连接池的最大值 --&
&property name="maxActive" value="10" /&
&!-- 最大空闲值.当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 --&
&property name="maxIdle" value="20" /&
最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请 --&
&property name="minIdle" value="10" /&
&property name="defaultAutoCommit" value="true" /&
&!-- 会话工厂 --&
&bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&
&property name="dataSource" ref="dataSource" /&
&property name="mappingLocations"&
&value&classpath:/com/nms/entity/**/*.hbm.xml&/value&
&/property&
&property name="hibernateProperties"&
&prop key="hibernate.dialect"&
org.hibernate.dialect.MySQL5Dialect
&prop key="hibernate.show_sql"&true&/prop&
&prop key="hibernate.format_sql"&true&/prop&
&/property&
&context:annotation-config /&
&context:component-scan base-package="com.dao" /&
&!-- 定义事务管理器 --&
&bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"&
&property name="sessionFactory" ref="sessionFactory" /&
&!-- 定义事务 --&
&tx:advice id="txAdvice" transaction-manager="transactionManager"&
&tx:attributes&
&tx:method name="*" propagation="REQUIRED" /&
&/tx:attributes&
&/tx:advice&
&!-- 定义切面 --&
&aop:config&
&aop:pointcut id="interceptorPointCuts" expression="execution(* com.dao.*.*(..))" /&
&aop:advisor advice-ref="txAdvice" pointcut-ref="interceptorPointCuts" /&
&/aop:config&
第五种:注解:
&?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"&
&!-- 数据源 --&
&bean id="dataSource"
class="mons.dbcp.BasicDataSource"
destroy-method="close"&
&property name="driverClassName" value="com.mysql.jdbc.Driver" /&
&property name="url"
value="jdbc:mysql://192.168.0.244:3306/test?useUnicode=true&characterEncoding=UTF-8" /&
&property name="username" value="root" /&
&property name="password" value="root" /&
&!-- 连接池启动时的初始值 --&
&property name="initialSize" value="10" /&
&!-- 连接池的最大值 --&
&property name="maxActive" value="10" /&
&!-- 最大空闲值.当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 --&
&property name="maxIdle" value="20" /&
最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请 --&
&property name="minIdle" value="10" /&
&property name="defaultAutoCommit" value="true" /&
&!-- 会话工厂 --&
&bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&
&property name="dataSource" ref="dataSource" /&
&property name="mappingLocations"&
&value&classpath:/com/nms/entity/**/*.hbm.xml&/value&
&/property&
&property name="hibernateProperties"&
&prop key="hibernate.dialect"&
org.hibernate.dialect.MySQL5Dialect
&prop key="hibernate.show_sql"&true&/prop&
&prop key="hibernate.format_sql"&true&/prop&
&/property&
&context:annotation-config /&
&!-- 使用注解的包路径 --&
&context:component-scan base-package="com.dao" /&
@Transactional 标记 --&
&tx:annotation-driven transaction-manager="transactionManager"/&
&!-- 定义事务管理器 --&
&bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"&
&property name="sessionFactory" ref="sessionFactory" /&
如果使用了注解,那么实现类应该这样写:
package com.dao.
import org.springframework.orm.hibernate3.support.HibernateDaoS
import org.
import org.springframework.transaction.annotation.T
import com.dao.UserD
@Transactional
@Component("userDaoAgency")
public class UserDaoImpl extends HibernateDaoSupport implements UserDao {
* 为方法增加事务处理特性
@Transactional(readOnly=true)
public void getUser(){
这样每个方法都能自己定义自己的事务处理!
请您到ITEYE看我的原创:
或支持我的个人博客,地址:
以上内容,是从网络找到的资料总结而来,仅供参考!
浏览 10438
论坛回复 /
(13 / 6922)
cuisuqiang
浏览: 2442655 次
来自: 北京
浏览量:2245273
学习了! 用了这个方法,就不会阻塞了
用setField返回一些简单,重要的信息,不要保存太多的信息 ...
写道为什么我下载你的mypushlet.ra ...
为什么我下载你的mypushlet.rar 怎么出不来 报40 ...
请问一下前端是怎么处理的啊Spring异常抛出触发事务回滚策略 - 黑。 - ITeye技术网站
博客分类:
Spring、EJB的声明式事务默认情况下都是在抛出unchecked exception后才会触发事务的回滚 测试用业务逻辑方法:
整个包裹起来,则这个业务方法也就等于脱离了spring事务的管理,因为没有任何异常会从业务方法中抛出!全被捕获并吞掉,导致spring异常抛出触发事务回滚策略失效。 不过,如果在catch代码块中采用页面硬编码的方式使用spring api对事务做显式的回滚,这样写也未尝不可。
public class TestServiceImpl extends Service implements TestService {
public void testAddPerson(String name) throws Exception {
TestPerson p = new TestPerson();
p.setName(name);
this.getHibernateGenericController().save(p);
throw new RuntimeException("抛出个运行时异常");
关于TransactionProxyFactoryBean的transactionAttributes中字符串的值(定义自TransactionAttributeEditor): is a transaction attribute descriptors that parsed via TransactionAttributeEditor 见本博客: 单元测试代码:
public class TestSpringDefaultRollback extends TestCase {
private static ApplicationContext context = new ClassPathXmlApplicationContext("resource/xxx/applicationContext.xml");
public void testDefaultRollback() throws Exception{
TestService testServiceImpl = (TestService)context.getBean("testService");
testServiceImpl.testAddPerson("张三");
将异常捕获,并且在catch块中不对事务做显式提交(或其他应该做的操作如关闭资源等)=生吞掉异常 spring的事务边界是在调用业务方法之前开始的,业务方法执行完毕之后来执行commit or rollback(Spring默认取决于是否抛出runtime异常). 如果抛出runtime exception 并在你的业务方法中没有catch到的话,事务会回滚。 一般不需要在业务方法中catch异常,如果非要catch,在做完你想做的工作后(比如关闭文件等)一定要抛出runtime exception,否则spring会将你的操作commit,这样就会产生脏数据.所以你的catch代码是画蛇添足。 由此可以推知,在spring中如果某个业务方法被一个
} catch(Exception e) {
浏览 10114
shaohan126448
浏览: 66231 次
来自: 北京
你好,能将demo源码发我下吗?jackclchan@qq.c ...
你好,能将demo源码发我下吗?@qq.co ...
你好,上面的demo 能发我一份了
deshanjiang8 ...
spring mvc demo教程源代码下载,地址:http: ...&&等spring同步关键词synchronized和事务锁@Transactional为什么还有并发?
@Transactional
@Service(&projFcd&)
public class ProjFcdImpl implements ProjFcd {
public synchronized Result investProject(InvestProjBO tp) throws ProjException {
}一个service类上加了@Transaction注解,在方法上加了synchronized关键字,可是最后还是发生了并发问题,是事务没配好,还是怎么回事?再问一句这里的事务锁和同步锁的进入出来顺序是怎么样的?1个牛币所有回答列表(7)是不是并发的时候,主键不一样了?ProjFcdImpl的scope不是配的singleton吗?试试配成 prototype@Transactional(isolation = Isolation.SERIALIZABLE)指定事务隔离级别可以解决你的问题。贴出里面业务详细代码&LV2如果应用是集群的就有可能并发呀!@Transactional &synchronized&要分开使用,因为加上@Transactional&spring AOP管理事务时,synchronized&并不起作用,可以新建一个不带事务的同步方法,该同步方法在调用investProject(InvestProjBO tp)方法。之前遇到过这种问题,可以尝试一下这样做。&LV4刚遇到此类问题,@Transactional和synchronized可以共存处理并发问题。等等等等等等等等等等等等最热搜索问答话题编程语言基础Web开发数据库开发客户端开发脚本工具游戏开发服务器软硬件开源组件类库相关问答等完等等等等等等等等完完最近浏览暂无贡献等级暂无贡献等级暂无贡献等级暂无贡献等级暂无贡献等级暂无贡献等级暂无贡献等级暂无贡献等级暂无贡献等级暂无贡献等级扫描二维码关注最代码为好友"/>扫描二维码关注最代码为好友Spring事务何时关闭 - ITeye问答
&bean id="DiscService"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"&
&property name="transactionManager" ref="transactionManager" /&
&property name="target"&
class="com.downloadmanage.service.impl.DiscServiceImpl"&
&property name="discDao" ref="DiscDAO"&&/property&
&/property&
&property name="transactionAttributes"&
&prop key="get*"&PROPAGATION_REQUIRED,readOnly&/prop&
&prop key="*"&PROPAGATION_REQUIRED&/prop&
&/property&
在applicationContext.xml中我给DiscService设置了事物
Disc和Game是one-to-many的关系,Game端为lazy加载
我在Junit里面有这样一个测试:
* 测试:输出找到的Disc的DiscNumber以检测延迟加载的情况
public void testAddGameForDisc(){
Disc disc = discService.findDiscByDiscNumber("M16");
System.out.println("找到这张盘,光盘的编号是: "+disc.getDiscNumber());
System.out.println("光盘内游戏有: "+disc.getGames().iterator().next().getGameName());
} catch (NotFoundInDBException e) {
System.out.println("没有这张光盘");
控制台给我的结果是:
Hibernate: select disc0_.disc_id as disc1_1_, disc0_.borrow_to as borrow2_1_, disc0_.disc_number as disc3_1_, disc0_.save_place as save4_1_ from downloadmanage.disc disc0_ where disc0_.disc_number=?
找到这张盘,光盘的编号是: M16
Hibernate: select games0_.game_in as game2_1_, games0_.game_id as game1_1_, games0_.game_id as game1_4_0_, games0_.game_in as game2_4_0_, games0_.game_type as game3_4_0_, games0_.game_name as game4_4_0_ from downloadmanage.game games0_ where games0_.game_in=?
光盘内游戏有: Diablo
也就是说Game类的确被lazy加载了,不过我预期的结果是
System.out.println("光盘内游戏有: "+disc.getGames().iterator().next
这个语句会报错,也即是说 他不应该再向数据库查询了。
我没有配置SessionInView模式,那怎么还会出现这种情况呢?
谢谢
问题补充:那请问一下 这个Session什么时候才关闭呢?
我已经调用完DiscServie 及从数据库库中读到这个Disc了,剩下的工作就是操作
这个未被完全初始化的Disc的业务操作了。和底层数据库没有关系了。
所以我想调用完
Disc disc = discService.findDiscByDiscNumber("M16");
就关闭Session 请问应该怎么写呢 ?
我的DAO层是直接用的Spring之中的getHibernateTemplate() 等于
是不是应该可以说Spring把Session的事情给我屏蔽掉了?
谢谢您的回答。
问题补充:我可能自己找到答案了,不过还是要您给看看我说得对不对。
当整个test工作在
public class DiscServiceImplTest extends
AbstractDependencyInjectionSpringContextTests {
模式下,效果和我想象的是一样的。
并且当test工作在
public class DiscServiceImplTest extends
AbstractTransactionalSpringContextTests {
整个模式下,但是我
System.out.println("找到这张盘,光盘的编号是: "+disc.getDiscNumber());
endTransaction();
System.out.println("光盘内游戏有: "+disc.getGames().iterator().next().getGameName());
手工调用了endTransaction();
也达到了相应目的。
也就是说其实DiscService的事物已经完成了,不过由于整个test具有事务性,通过事物的传递,所以当test没有运行完成之前 事物是一直打开的
我说的对么?
采纳的答案
1, lz理解是正确的.每个AbstractTransactionalSpringContextTests中的test方法确实是被自动的添加在事务里面了!而且默认情况下, 这个被添加的事务还是[readOnly = false], 也就是说, 就算你的discService不加事务, 你的save(), saveOrUpdate()操作也是可以执行的.但是如果Override下面这个方法:
@Override
protected void onSetUp() throws Exception {
DefaultTransactionDefinition td = (DefaultTransactionDefinition) transactionD
td.setReadOnly(true);
super.onSetUp();
}
, 就会抛错:
org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session MIT/AUTO or remove 'readOnly' marker from transaction definition......., 这也算是AbstractTransactionalSpringContextTests的一个magic吧
2, 如果lz没有配置SessionInView模式, 那么在jsp页面中使用jstl读取disc的games的数据的时候, 就会出错, 因为这时session已经关掉了!想想, 如果你的Action(或Controller)不在事务中, 同样也会出错吧!哈哈!
这个和Spring事务没有关系.
Hibernate中,从session中得到的对象是被代理过的,当lazy加载的时候,调用这个对象的一个方法就会lazy载入数据. 应该没有问题的.
你这样测试反而是证明了Hibernate的Lazy加载.
已解决问题
未解决问题}

我要回帖

更多关于 华硕x540up内存条卡槽在哪 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信