openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Struberg <strub...@yahoo.de>
Subject JPA inter-vendor compatibility and the spec
Date Sun, 03 Jun 2012 09:12:21 GMT
Hi folks!

I remember having talked with one of you in the past why the following properties are NOT
enabled by default:

 <property name="openjpa.DetachState" value="loaded(DetachedStateField=true)"/>
 <property name="openjpa.Compatibility" value="IgnoreDetachedStateFieldForProxySerialization=true"/>

This basically tells OpenJPA to also serialise (externalise) the _dirty and _loaded fields
along with each entity and restore this info in the DetachedStateManager on de-serialisation.
What I remember is that someone said that this is against the spec. Do you recall which spec
paragraph / TCK test this was?

The second option is a bit more tricky and deals with out internal handling of proxies when
serialising. From looking at the source I think the name is a bit confusing. What it does
is to always serialize the whole proxy in any case. Please also not that this behaviour was
the default in OpenJPA-1.x and only gets changed if your persistence.xml version is "2.0".


I basically _always_ use those 2 magic flags nowadays, because it's the only way you can do
serialisation without loosing data imo.

There is a little bit of discussions and the pitfalls I had with this options in https://issues.apache.org/jira/browse/OPENJPA-1933
It still doesn't explain why this behaviour was put there initially.
The best source I could find is 

https://issues.apache.org/jira/browse/OPENJPA-1097 and
https://issues.apache.org/jira/browse/OPENJPA-968

The best thing explaining this restriction I could find in the JPA spec is:

"Serializing entities and merging those entities back into a persistence context may not be
interoperable across vendors when lazy properties or fields and/or relationships are used.
A vendor is required to support the serialization and subsequent 
deserialization and merging of detached entity instances (which may 
contain lazy properties or fields and/or relationships that have not 
been fetched) back into a separate JVM instance of that vendor’s 
runtime, where both runtime instances have access to the entity classes 
and any required vendor persistence implementation classes."

But  reading this again and again it seems to me that this is _not_ against applying the
above properties by default.



Do we still have a bug in there (and we shall fix it), or is this area not clearly defined
in the spec (and we should aim to get it fixed in JPA-2.1)?



LieGrue,
strub


Mime
View raw message