Can't write to a readonly object with Hibernate read-only second-level cache

If you enabled read-only second-level cache in Hibernate and have the following error:

Stack Trace:
* org.hibernate.cache.ReadOnlyCache.lock(ReadOnlyCache.java:43)
* org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:69)
* org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
* org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
* org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
* org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
* org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
* org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
* org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
* org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)

which also shows up in Eclipse like this:

ERROR org.hibernate.cache.ReadOnlyCache : Application attempted to edit read only item

Check that your Hibernate class mapping has mutable="false", which prevents Hibernate from issuing updates for already existing instances. Here is a link to my Hibernate Forums thread about this problem.