You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Kevin Sutter (JIRA)" <ji...@apache.org> on 2007/08/25 16:11:30 UTC

[jira] Created: (OPENJPA-337) Throw an exception on access to unloaded fields in detached objects

Throw an exception on access to unloaded fields in detached objects
-------------------------------------------------------------------

                 Key: OPENJPA-337
                 URL: https://issues.apache.org/jira/browse/OPENJPA-337
             Project: OpenJPA
          Issue Type: Improvement
          Components: jpa
    Affects Versions: 0.9.7
            Reporter: Kevin Sutter


Due to the Hibernate -> OpenJPA migration article in this month's devWorks, Patrick and I discussed a couple of alternatives to returning nulls on unloaded fields on detached objects:

(http://www.ibm.com/developerworks/websphere/techjournal/0708_vines/0708_vines.html?ca=drs-)

>From the article:
"It is also worth noting that Hibernate and OpenJPA differ in
accessing a lazy loaded collection from a detached object. In
Hibernate, an exception will be thrown if the programmer attempts to
access a lazy loaded collection on a detached object; while OpenJPA
will return a null value, not an exception."

Patrick's response:
Actually, this depends on the openjpa.DetachedState setting. If
appropriately configured, OpenJPA will throw on any unloaded field
access when detached. The downside is that it changes the
serialization footprint of the class.

Also, I just thought of a way for us to throw exceptions for
collection access even when not using that setting -- we could put
Collection / Map impls into place that just throw when any method is
invoked.



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.