![](/img/trans.png)
[英]UnsupportedOperationException when merging an existing Hibernate model object?
[英]handling hibernate UnsupportedOperationException: Can't write to a readonly object
我需要設置哪些配置參數或會話首選項來解決這個問題? 無法寫入只讀對象? 這是更多信息的堆棧跟蹤:
Caused by: java.lang.UnsupportedOperationException: Can't write to a readonly object
at org.hibernate.cache.ReadOnlyCache.lock(ReadOnlyCache.java:43)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:85)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at com.mycompany.arch.submission.registry.bean.RegSubmissionSpringService.perform_flush(RegSubmissionSpringService.java:1108)
at com.mycompany.arch.submission.registry.bean.RegSubmissionSpringService.saveRegistryData(RegSubmissionSpringService.java:1062)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy145.saveRegistryData(Unknown Source)
at com.mycompany.arch.submission.registry.bean.RegDataAccessManager.persistRegistry(RegDataAccessManager.java:54)
看看這個博客頁面是否有用:
檢查您的 Hibernate 類映射是否具有 mutable="false",這會阻止 Hibernate 為現有實例發布更新。 這是我關於這個問題的 Hibernate 論壇線程的鏈接。
對於我們中間的懶惰/愚蠢的人(比如我;))
改變
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
進入
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
(例如)
(在數據庫類型 pojo 中)
也可能有幫助:)
S。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.