Domanda

I am working on ofbiz. Am just trying to delete a record from a table, in which there is a field with an auto generated sequence id. Am trying to delete the record by simple method, using tag. But it is showing below error:

 [java] 2014-03-13 11:23:22,584 (http-bio-0.0.0.0-8080-exec-9) [                Log.java:83 :INFO ] 
 [java] 2014-03-13 11:23:22,599 (http-bio-0.0.0.0-8080-exec-9) [      GenericEntity.java:147:ERROR] 
 [java] ---- runtime exception report --------------------------------------------------
 [java] Exception: java.lang.IllegalStateException
 [java] Message: **This object has been flagged as immutable (unchangeable), probably because it came from an Entity Engine cache. Cannot modify an immutable entity object.**
 [java] ---- stack trace ---------------------------------------------------------------
 [java] java.lang.IllegalStateException: This object has been flagged as immutable (unchangeable), probably because it came from an Entity Engine cache. Cannot modify an immutable entity object.
 [java] org.ofbiz.entity.GenericEntity.assertIsMutable(GenericEntity.java:147)
 [java] org.ofbiz.entity.GenericEntity.removedFromDatasource(GenericEntity.java:276)
 [java] org.ofbiz.entity.GenericDelegator.removeValue(GenericDelegator.java:1081)
 [java] org.ofbiz.minilang.method.entityops.RemoveValue.exec(RemoveValue.java:66)
 [java] org.ofbiz.minilang.SimpleMethod.runSubOps(SimpleMethod.java:311)
 [java] org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:458)
 xxxxxxxxx xxxxx .................

Can't we delete this type of records(those have auto generated sequence id) from db table?

È stato utile?

Soluzione 2

My self found the solution. Actually, when I am retrieving the record, I used "entity-one" tag in which, use-cache is "true" by default. So I changed the value use-cache to false. So, I am able to delete the record. The below are the snippets I used while retrieving record:

 <entity-one value-field="xxx" entity-name="Yyyyy">...</entity-one>
 <remove-value value-field="xxx"/>

Now I specified use-cache attribute to false as below:

 <entity-one value-field="xxx" entity-name="Yyyyy" **use-cache="false"**>...</entity-one>
 <remove-value value-field="xxx"/>

It's working fine. Thank you.

Altri suggerimenti

You must clone immutable instances from cache first to modify them. Here is a thread with little bit explanation.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top