java.lang.UnsupportedOperationException: Can't write to a readonly object>java.lang.UnsupportedOperationException: Can't write to a readonly object

Hibernate JIRA | Loren Rosen | 1 decade ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    I'm getting the message "AssertionFailure - -An AssertionFailure occured - this may indicate a bug in Hibernate". Here's the situation: I have a class with read-only caching (<cache usage="read-only"/>. But I do not have mutable="false" for this class-- perhaps that doesn't make sense, but I thought I should at least report the problem I stumbled on while trying to run this setup, before I change my configuration. First, I create a new object (via new.... Session.save.... Transaction.commit). This does do the database insert (which perhaps it shouldn't do in this configuration). Next, in a new session with a new transaction, I take the same object, and delete it (via Session.delete.... Transaction.commit). This gets an exception on the commit, "java.lang.UnsupportedOperationException: Can't write to a readonly object", which is reasonable. Now the code goes to the exception handler, which naturally attempts to rollback the transaction. This raises another exception, with the "may indicate a bug message" : [DEBUG] JDBCTransaction - -rollback [ERROR] ReadOnlyCache - -Application attempted to edit read only item: 360449 [ERROR] AssertionFailure - -An AssertionFailure occured - this may indicate a bug in Hibernate <java.lang.UnsupportedOperationException: Can't write to a readonly object>java.lang.UnsupportedOperationException: Can't write to a readonly object at net.sf.hibernate.cache.ReadOnlyCache.release(ReadOnlyCache.java:47) at net.sf.hibernate.impl.ScheduledDeletion.afterTransactionCompletion(ScheduledDeletion.java:34) at net.sf.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:530) at net.sf.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:90) at com.loren.DocumentExample.deleteTestDoc(DocumentExample.java:617) at com.loren.DocumentExample.main(DocumentExample.java:71) Exception in thread "main" net.sf.hibernate.AssertionFailure: Exception releasing cache locks at net.sf.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:541) at net.sf.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:90) at com.loren.DocumentExample.deleteTestDoc(DocumentExample.java:617) at com.loren.DocumentExample.main(DocumentExample.java:71) Caused by: java.lang.UnsupportedOperationException: Can't write to a readonly object at net.sf.hibernate.cache.ReadOnlyCache.release(ReadOnlyCache.java:47) at net.sf.hibernate.impl.ScheduledDeletion.afterTransactionCompletion(ScheduledDeletion.java:34) at net.sf.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:530) ... 3 more

    Hibernate JIRA | 1 decade ago | Loren Rosen
    java.lang.UnsupportedOperationException: Can't write to a readonly object>java.lang.UnsupportedOperationException: Can't write to a readonly object
  2. 0

    I'm getting the message "AssertionFailure - -An AssertionFailure occured - this may indicate a bug in Hibernate". Here's the situation: I have a class with read-only caching (<cache usage="read-only"/>. But I do not have mutable="false" for this class-- perhaps that doesn't make sense, but I thought I should at least report the problem I stumbled on while trying to run this setup, before I change my configuration. First, I create a new object (via new.... Session.save.... Transaction.commit). This does do the database insert (which perhaps it shouldn't do in this configuration). Next, in a new session with a new transaction, I take the same object, and delete it (via Session.delete.... Transaction.commit). This gets an exception on the commit, "java.lang.UnsupportedOperationException: Can't write to a readonly object", which is reasonable. Now the code goes to the exception handler, which naturally attempts to rollback the transaction. This raises another exception, with the "may indicate a bug message" : [DEBUG] JDBCTransaction - -rollback [ERROR] ReadOnlyCache - -Application attempted to edit read only item: 360449 [ERROR] AssertionFailure - -An AssertionFailure occured - this may indicate a bug in Hibernate <java.lang.UnsupportedOperationException: Can't write to a readonly object>java.lang.UnsupportedOperationException: Can't write to a readonly object at net.sf.hibernate.cache.ReadOnlyCache.release(ReadOnlyCache.java:47) at net.sf.hibernate.impl.ScheduledDeletion.afterTransactionCompletion(ScheduledDeletion.java:34) at net.sf.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:530) at net.sf.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:90) at com.loren.DocumentExample.deleteTestDoc(DocumentExample.java:617) at com.loren.DocumentExample.main(DocumentExample.java:71) Exception in thread "main" net.sf.hibernate.AssertionFailure: Exception releasing cache locks at net.sf.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:541) at net.sf.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:90) at com.loren.DocumentExample.deleteTestDoc(DocumentExample.java:617) at com.loren.DocumentExample.main(DocumentExample.java:71) Caused by: java.lang.UnsupportedOperationException: Can't write to a readonly object at net.sf.hibernate.cache.ReadOnlyCache.release(ReadOnlyCache.java:47) at net.sf.hibernate.impl.ScheduledDeletion.afterTransactionCompletion(ScheduledDeletion.java:34) at net.sf.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:530) ... 3 more

    Hibernate JIRA | 1 decade ago | Loren Rosen
    java.lang.UnsupportedOperationException: Can't write to a readonly object>java.lang.UnsupportedOperationException: Can't write to a readonly object

    Root Cause Analysis

    1. java.lang.UnsupportedOperationException

      Can't write to a readonly object>java.lang.UnsupportedOperationException: Can't write to a readonly object

      at net.sf.hibernate.cache.ReadOnlyCache.release()
    2. net.sf.hibernate
      JDBCTransaction.rollback
      1. net.sf.hibernate.cache.ReadOnlyCache.release(ReadOnlyCache.java:47)
      2. net.sf.hibernate.impl.ScheduledDeletion.afterTransactionCompletion(ScheduledDeletion.java:34)
      3. net.sf.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:530)
      4. net.sf.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:90)
      4 frames
    3. com.loren
      DocumentExample.main
      1. com.loren.DocumentExample.deleteTestDoc(DocumentExample.java:617)
      2. com.loren.DocumentExample.main(DocumentExample.java:71)
      2 frames