[英]Java / Hibernate - Write operations are not allowed in read-only mode
[英]How should I overcome from this hibernate error of java Write operations are not allowed in read-only mode
在只讀模式(FlushMode.MANUAL)中不允許進行寫操作:將您的Session變為FlushMode.COMMIT / AUTO或從事務定義中刪除“ readOnly”標記。 在org.springframework.orm.hibernate4.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1135)
在您的Spring上下文部分中,設置以下內容。
<!--default is required transaction-->
<tx:method name="*"/>
我認為您的當前設置為:
<tx:method name="*" read-only="true" propagation="REQUIRED" />
您還可以將@Transactional(readOnly = false)設置為需要寫入數據庫的類方法(例如,持久性,更新或刪除之類的DAO類方法)。
@Transactional(readOnly = false)
public void UpdateEmployee() {
...
...
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.