关于 org.springframework.dao.InvalidDataAccessApiUsageException问题
发表在JavaWeb图书答疑 2013-03-24
是否精华
版块置顶:
今天做一个项目的时候出现了这个问题
org.springframework.dao.InvalidDataAccessApiUsageException:Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.

这是我的配置文件中的信息,我配置了delete*,而且在service中使用的方法也是delete开头的。
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="Delete*" propagation="REQUIRED" />
<tx:method name="modify*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice>
<!-- 配置哪些类的哪些方法参与事务 -->
<aop:config>
<aop:pointcut id="allServiceMethod" expression="execution(* service.*.*(..))" />
<aop:advisor pointcut-ref="allServiceMethod" advice-ref="txAdvice" />
</aop:config>
    
这是我的dao里面的代码
public void deleteXJGZ(final String gzdh,final String xjgzmc) {
// TODO Auto-generated method stub
this.getHibernateTemplate().delete(this.getHibernateTemplate().execute(new HibernateCallback() {

@Override
public Object doInHibernate(Session arg0) throws HibernateException,
SQLException {
// TODO Auto-generated method stub
Query query=arg0.createQuery("from XJGZ where tsnum = ? and tsname = ?");
query.setParameter(0, gzdh);
query.setParameter(1, xjgzmc);
return (XJGZ)query.uniqueResult();
}
}));
}
真的不知道什么原因了,看网上改了好多,也没什么作用还是这个问题,求帮忙解决啊,谢谢
分享到:
精彩评论 1
无语_mrkj
学分:3155 LV11
2013-04-17
沙发
请问这是哪本书中的问题?
首页上一页 1 下一页尾页 1 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照