openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter (JIRA)" <>
Subject [jira] Created: (OPENJPA-337) Throw an exception on access to unloaded fields in detached objects
Date Sat, 25 Aug 2007 14:11:30 GMT
Throw an exception on access to unloaded fields in detached objects

                 Key: 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:


>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

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

View raw message