I'm using OpenJPA with GWT, and therefore I'm copying my model object to a
GWT friendly DTO, before passing it to the frontend (and visa versa when
returning from the frontend).
When I check my debug output, I notice that there are update statements for
entities that are supposed to be immutable (the database values don't
change).
So I tried removing cascade = { CascadeType.PERSIST,CascadeType.MERGE }, to
prevent the immutable entity from getting updated, but then I get this
error:
org.apache.openjpa.persistence.InvalidStateException: Encountered unmanaged
object in persistent field
Then I added this method to my DAO:
public TblScmpdt attachImmutableRelationships(TblScmpdt tblScmpdt){
EntityManager em = getEntityManager();
TblPdtcde tblPdtcde =
em.find(TblPdtcde.class,tblScmpdt.getPdtcdeId());
tblScmpdt.setTblPdtcde(tblPdtcde);
return tblScmpdt;
}
but I still get the InvalidStateException.
How do I stop OpenJPA from trying to merge/persist my immutable entities?
--
View this message in context:
http://n2.nabble.com/How-to-prevent-OpenJPA-from-updating-immutable-entities--tp721855p721855.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.