not allowed in read-only mode (FlushMode.NEVER) 解决

群晖设置公网ipv6方式域名解析访问 群晖、IPV6、域名解析 阅读详情

在用spring.net + Nhibernate进行数据库访问时回出现如下错误:

Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition

至于产生错误的原因可以参考: http://www.diybl.com/course/3_program/java/javajs/20071018/77920.html

 

当然出现这个错误和保持一个Session有关系

我在web.xml里添加

<add name="OpenSessionInView" type="Spring.Data.NHibernate.Support.OpenSessionInViewModule, Spring.Data.NHibernate12"/>

来确保一个次请求会话中保持使用一个数据会话连接.

那么如何解决这个问题呢? 那就是采用spring.net的事物机制.

 

添加以下配置脚本

<object id="autoProxyCreator"
            type="Spring.Aop.Framework.AutoProxy.DefaultAdvisorAutoProxyCreator, Spring.Aop">
  </object>

  <!--事务顾问-->
  <object id="transactionAdvisor"
          type="Spring.Transaction.Interceptor.TransactionAttributeSourceAdvisor, Spring.Data">
    <property name="TransactionInterceptor" ref="transactionInterceptor"/>
  </object>

   
  <!--事务拦截器-->
  <object id="transactionInterceptor"
          type="Spring.Transaction.Interceptor.TransactionInterceptor, Spring.Data">
    <property name="TransactionManager" ref="HibernateTransactionManager"/>
     <!--note do not have converter from string to this property type registered-->
    <property name="TransactionAttributeSource" ref="attributeTransactionAttributeSource"/>
  </object>

 

  <object id="attributeTransactionAttributeSource"
          type="Spring.Transaction.Interceptor.AttributesTransactionAttributeSource, Spring.Data">
  </object>

 

然后在需要事务处理的代码加上方法属性。例如:

[Transaction(Spring.Transaction.TransactionPropagation.Required, ReadOnly = false)]
public void SaveOrUpdate(CompanyInfo info)
{
        dao.SaveOrUpdate(info);
}

【ESP32 S3 开发】基于I2S协议驱动INMP441数字麦克风 实现语音采集 注意INMP441的 L/R接地之后才稳定输出数据 否则一直都是0WAV格式说明这里主要是想说wav文件重要的就是生成一个wavhead来标识它是一个wave文件,wave文件的data chunk 中的data部分还是PCM编码格式的数据,直接从I2S读进去就可以,不需要压缩。wav文件的头一般由4个chunk组成。 以16bit深度为例,代码如下。其他深度可以根据注释自行计算。 I2S -> DAC i2s_read()函数,向flash中划分的一个buff当中读入byte数组。以16bit深度为例,一 阅读详情

相关推荐

高通平台power_supply 框架下添加第三方充电IC的驱动方法

1.power_supply电源框架介绍: power supply framework在kernel/drivers/power/下。内核抽象出来power supply子系统为驱动提供了统一的框架。 功能包括: 1.抽象PSY设备的共性,向用户空间提供统一的API; 2.为底层PSY驱动的编写,提供简单、统一的方式,同时封装并实现公共逻辑。 power supply class位于d...

Change 1万+

异常:Write operations are not allowed in read-only mode (FlushMode.NEVER)

我用Spring的声明事务,增加一个业务功能时,我出现了异常: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition ...

木木的点滴 307

deepseek本地部署及应用部署指南

如果你找到的日志是[send] via NET/IB/0,则表示网络通信是通过IB网络的,但是没有开启GDRDMA技术,则会有大致5%的性能损耗(网传,未实测)。新增的环境变量配置,主要用于启用IB网络通信,而非使用以太网进行通信,详细的每一个参数的具体含义,可以在英伟达NCCL的官方网站上找到说明。下一步,我会对已经完成部署的模型进行压测,来探索系统的性能极限在哪里,以及如何在生产环境中何如进行进一步的性能优化,期待你的关注。

weixin_39797121的博客 2624

Write operations are not allowed in read-only mode错误解决

最近在配置 Struts, Spring 和Hibernate整合的问题: 开启OpenSessionInViewFilter来阻止延迟加载的错误的时候抛出了这个异常:     org.springframework.dao.InvalidDataAccessApiUsageException错误 但是在我们开启OpenSessionInViewFilter这个过滤器的时候FlushMode...

错误集中营 5万+

OpenWebUI联网搜索实战:如何用SearXNG让本地大模型获取实时信息(附百度/360配置)

本文详细介绍了如何通过部署开源元搜索引擎SearXNG,为本地运行的OpenWebUI大语言模型(如Qwen、Llama)配置联网搜索功能,解决其知识库过时的问题。文章重点讲解了SearXNG的Docker部署、集成国内搜索引擎(如百度、360)的配置方法,以及如何与OpenWebUI无缝对接,从而实现本地大模型获取实时、准确的中文信息,提升其实用性。

weixin_28835583的博客 1876

Unity XR Interaction Toolkit(二)手柄交互

XR Interaction 手柄事件和抓取设置

qq_36608844的博客 8496

关于spring+hibernate的read-only mode

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 r

wgj85的专栏 7802

超声波传感器(CHx01) 学习笔记 Ⅲ-API介绍

超声波传感器(CHx01) API介绍

nicole088的专栏 1387

Write operations are not allowed in read-only mode 只读模式下(FlushMode.NEVER/MANUAL)写操作不允许

第一种解决办法 org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remo

彷徨de等待 3224

[网络安全自学篇] 六.OllyDbg动态分析工具基础用法及Crakeme逆向破解

这是作者的系列网络安全自学教程,主要是关于网安工具和实践操作的在线笔记,特分享出来与博友共勉,希望您们喜欢,一起进步。上一篇文章分享了IDA Pro反汇编工具的基础用法,并简单讲解一个EXE逆向工程解密实战方法;本篇文章将讲解动态分析OllyDbg工具的基础用法,主要是结合两个Crakeme案例逆向破解。希望对初学者有帮助,大神请飘过,谢谢各位看官!

杨秀璋的专栏 1万+

OpenClaw一人公司落地案例:本地商家营销智能体月赚3万的秘密

角色:本地商家营销专家## 核心目标为商家生成高转化率的抖音营销策略,最大化 ROI。## 输入数据- 商家名称: "XX奶茶店"- 过去 30 天视频播放量: 12,000- 客单价: 28 元- 竞品平均播放量: 15,000- 市场趋势: rising## 策略生成规则1. **内容类型**:根据客单价推荐- < 30 元:美食探店 + 优惠券- > 30 元:场景化故事 + 会员权益2. **发布时间**:根据历史数据- 18:00-20:00 高峰期。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 542

错误:Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)

这几天,碰到个错误: org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or rem

吴静的blog 1万+

深度学习时间序列预测:GRU算法构建多变量时间序列预测模型+代码实战

深度学习多变量时间序列预测:GRU算法构建多变量时间序列预测模型+代码实战 注意参考:深度学习多变量时间序列预测:GRU算法构建单变量时间序列预测模型+代码实战 GRU(Gate Recurrent Unit)是循环神经网络(Recurrent Neural Network, RNN)的一种。和LSTM(Long-Short Term Memory)一样,也是为了解决长期记忆和反向传播中的梯度等问题而提出来的。 GRU和LSTM在很多情况下实际表现上相差无几,那么为什么我们要使用新人GRU(.

data+scenario+science+insight 4033

Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)异常解决方法

发生如下异常: Write operations are not allowed in read-only mode(FlushMode.NEVER/MANUAL).. 解决方法,在web.xml里面的OpenSessionInViewFilter配置初始化参数,如下 hibernateFilter org.springframework.orm.hibernate3.suppor

wang623145708的专栏 1578

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

Write operations are not allowed in read-only mode (FlushMode.NEVER) 错误解决

错误代码:org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' m...

小宝 179

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

open Session in view出现错误的解决方法Write operations are not allowed in read-only mode (FlushMode.NEVER) - ...

Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition 错误代码:   org.springframewo...

qingfengxia2013的专栏 140

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

hibernate异常:解决Hibernate的Write operations are not allowed in read-only mode (FlushMode.NEVER) ........

报错: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition 解决方法: 在方法体中加入 getHiber...

diwenzhan7700的博客 277

open Session in view出现错误的解决方法Write operations are not allowed in read-only mode (FlushMode.NEVER) -

使用Spring提供的Open Session In View而引起Write operations are not allowed in read-only mode (FlushMode.NEVER) 错误解决:在没有使用Spring提供的Open Session In Vi

1132

hibernate异常:解决Hibernate的Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL):

错误信息: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 're...

HD243608836的博客 1587

使用Spring提供的Open Session In View而引起Write operations are not allowed in read-only mode (FlushMode.NEVER) 错误解决

     在没有使用Spring提供的Open Session In View情况下,因需要在service(or Dao)层里把session关闭,所以lazy loading 为true的话,要在应用层内把关系集合都初始化,如 company.getEmployees(),否则Hibernate抛session already closed Exception; Open Session In

a1234567777777的专栏 769

解决 Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session in

采用spring的事务声明  <bean id="baseTransaction" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">

jazywoo_在路上 1069

Hibernate和spring结合的OpenSessionInViewFilter

看到了关于Spring提供的Open Session In View的一篇文章,很详细的介绍了相关细节。下面的文章转载自: 【http://blog.sina.com.cn/s/blog_5dc12c490100crr5.html】 使用Spring提供的Open Session In View而引起Write operations are not allowed in rea

lizhibin3944的专栏 613

Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)

在使用Spring+Hibernate或Spring+Hibernate+Struts进行增删改时会提示: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL) 分析原因如下: 在使用Spring+Hibernate或Spring+Hibernate+Struts的时候,会开启OpenSessi

JavaQ 3050

Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly

 错误代码:  org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove readOnly ma

我的世界我的梦 5104

Code Recyclebin Contact me QQ:149906878 Write operations are not allowed in read-only mode (FlushMo

方法一: 遇到这个情况,我猜: 1、你一定使用的spring+hibernate 2、你一定在applicationContext.xml文件中写了事务配置如下: Xml代码       tx:advice id="txAdvice" transaction-manager="transactionManager">          tx:attributes>

pingpinggaga的博客 670
上一篇: spring.net Could not initialize proxy - the owning Session was closed 解决
下一篇: NHibernate 中 Inverse 含义解释
2000killer
博客等级 码龄23年 5粉丝 35原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值