關於hibernate中插入資料報read-only mode只讀模式錯誤
專案中有時候會遇到插入資料到表中去報錯只讀模式
org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
這種錯誤如果之前一直沒有,且未曾修改app-config-context.xml配置檔案,突然就出現了此類問題,一般都是由於自己開發中方法名取名和配置檔案中配置項衝突
例如方法名取名為 public void getsomething(){},若此方法中有事務提交(增、刪、改)表操作,將會報上述錯誤,因為配置項中已經配置get*為只讀模式,故只需將自己方法名中的get去掉或替換即可。
再重啟服務測試,此時發現問題得以解決!!
相關推薦
關於hibernate中插入資料報read-only mode只讀模式錯誤
專案中有時候會遇到插入資料到表中去報錯只讀模式 org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (F
hibernate框架學習錯誤集錦-org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL)
context intern session ati log ali opera operation marker 最近學習ssh框架,總是出現這問題,後查證是沒有開啟事務。 如果采用註解方式,直接在業務層加@Transactional 並引入import or
java mybatis 關於中向資料庫中插入資料時,報錯java.lang.NullPointerException的問題
今天在實現向MySQL的資料庫insert一個Object資料時出現一個錯誤; org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptio
關於java中向資料庫中插入資料時,報錯Caused by: java.lang.NullPointerException的問題
今天在實現一個update資料時出現一個錯誤; org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
SQL Server中,插入資料報錯
有時候在一個表中插入資料,(插入語句都正常,沒有任何錯誤)但是插入報錯,這時候可以查詢一下是否這張表是否加了trigger(觸發器),導致資料插入失敗的。、 還有類似的刪除操作也有可能出現這種情況。 假如正常的插入語句,但是表加了觸發器,如下觸發器: 假設當前的資料庫是
Oracle 中關於database的read only狀態和read write狀態下普通使用者對資料的操作
當為了防止使用者程序修改資料庫中的資料時,可以將資料庫的狀態置為只讀,sql語句如下: startup mount alter database open read only;【注意:alter database *** 命令需要在database為mount狀態下才行,如
使用Hibernate向Oracle中插入資料
Hibernate是ORMapping的實現,通過一個類實現資料庫操作例項:hibernate.cfg.xml:Hibernate環境配置檔案 程式程式碼<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE hibe
通過資料庫批量向kettle中插入資料,建立trans和job的模板(按照不同的要求需要自行調整)
import psycopg2 # 用來操作資料庫的類 class GPCommand(object): # 類的初始化 def __init__(self): self.hostname = 'XXX.XX.X.XX' self.username
mybatis 在oracle資料庫中插入資料時獲取自增ID sequence序列
在oracle中sequence就是序號,每次取的時候它會自動增加。sequence與表沒有關係。 Create Sequence 首先要有CREATE SEQUENCE或者CREATE ANY SEQUENCE許可權。 建立語句如下: CREATE SEQUEN
Mybatis的mapper.xml檔案中插入資料返回自增主鍵
使用MyBatis往MySQL資料庫中插入一條記錄後,返回該條記錄的自增主鍵值。Mapper檔案應該怎麼寫呢? Mybatis的Mapper的標籤中有一個屬性,我們一起來看看: useGenerateKeys這個屬性,意思就是使用自增。我們需要將這個欄位設定為 true 。 同時,還需
InvalidDataAccessApiUsageException:Write operations are not allowed in read-only mode (FlushMode.NEV
錯誤截圖: 錯誤描述: org.springframework.dao.InvalidDataAccessApiUsageException:Write operations are not allowed in read-only mode (FlushMode.NEVER/MAN
從表中插入資料到另外一張表
方法一: 程式碼 1 select into 和 insert into select 兩種表複製語句 2 select * into destTbl from srcTbl 3 4 insert into destTbl(fld1, fld2) sele
在hibernate中查詢資料的 session中get 和load的區別:
* 第一點.傳送SQL的時機: * load這個方法採用了一個技術.lazy延遲載入(懶載入).真正使用這個物件的資料的時候.(物件的資料不包括主鍵). * get這個方法是立即檢索.當執行session.get()方法的時候,馬上傳送SQL語句查詢. * 第二點.返回的物件:
通過資料庫批量向kettle中插入資料
import psycopg2 用來操作資料庫的類 class GPCommand(object): # 類的初始化 def init(self): self.hostname = ‘10.1.2.42’
mysql中插入資料value與values的區別
value與values區別 VALUE插入多行 VALUES插入多行 對比之下,插入多行時,用VALUE比較快 根據所得出的結論,應該在插入單行的時候使用VALUES,在插入多行的時候使用VALUE 吐槽一下: 不得不說,這真的和他們兩個的名字相反,真奇
java向MySql資料庫中插入資料
package test; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLExc
用SQL語句向表格中插入資料
向表格中插入資料 SQL語言使用insert語句向資料庫表格中插入或新增新的資料行。Insert語句的使用格式如下: insert into tablename (first_column,...last_column) values (first_v
在資料(MS-SQL)表中插入資料和更新資料
insert into dbo.time -- insert data (id,name) values(3, 'herry'); update dbo.time1 set id=4 where name='coly' -- update data
ORACLE向表中插入資料的不同方法
---恢復內容開始--- 最近開始學習ORACLE了,作為一名萌新,分享一下學習心得,有錯誤的地方歡迎批評指正。 今天介紹一下向ORACLE資料庫表中插入資料的兩種方法。 1.第一種結構 INSERT INTO TABLE_NAME(COLUNMN1,COLUNMN2...) VALUES
使用JDBC向SqlServer資料庫中插入資料
在實際的開發的當中 我們會發現在資料庫中插入資料是比查詢資料難的 因為查詢只需要一個固定的值就可以進行查詢 但是插入的話需要對照資料庫的建表 因為有些鍵值不允許為空 示例程式碼: package sqlserver.controller; im