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(
* org.hibernate.action.EntityUpdateAction.execute(
* org.hibernate.engine.ActionQueue.execute(
* org.hibernate.engine.ActionQueue.executeActions(
* org.hibernate.engine.ActionQueue.executeActions(
* org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(
* org.hibernate.event.def.DefaultFlushEventListener.onFlush(
* org.hibernate.impl.SessionImpl.flush(
* org.hibernate.impl.SessionImpl.managedFlush(
* org.hibernate.transaction.JDBCTransaction.commit(

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.