openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter (JIRA)" <>
Subject [jira] [Commented] (OPENJPA-2483) Detached Entities and Lazy Loading behavior breaks portability
Date Wed, 12 Mar 2014 20:04:43 GMT


Kevin Sutter commented on OPENJPA-2483:

I doubt you are going to get all three major JPA providers to agree on an implementation just
be opening bug reports...  There's probably a reason why the spec is nebulous in this area.
 All three of these providers have reps on the JPA expert group.  When items can't be resolved
by the expert group, they turn into "provider-specific" implementations.  I'm guessing that's
what we have here.  It will be interesting to hear what kind of feedback you get with the
other bug trackers.

But, specific to your OpenJPA question...  We do provide a means of altering the processing
when attempting to access lazy fields in a detached entity.  In this section of the manual
[1], there is a property setting for throwing an exception instead of just getting a "null":

AccessUnloaded: Whether to allow access to unloaded fields of detached objects. Defaults to
true. Set to false to throw an exception whenever an unloaded field is accessed. This option
is only available when you use detached state managers, as determined by the settings above.


> Detached Entities and Lazy Loading behavior breaks portability
> --------------------------------------------------------------
>                 Key: OPENJPA-2483
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>            Reporter: icarus
>            Priority: Critical
> Hello everyone!
> I’ve created this bug in the EclipseLink, Hibernate and OpenJPA bugtracker because
I think that the current situation is very unsatisfying for every developer that tries to
develop portable Java EE applications.
> I know the JPA specification says about this:
> “When interoperability across vendors is required, the application must not use lazy
> But is the current situation really necessary? Let me summarize the behavior on accessing
the relations of a detached entity among the different JPA vendors:
> OpenJPA:
> The getter methods returns always “null” in this case. No exception is thrown, and
no access to the database.
> I could not find a possibility to change this behavior.
> EclipseLink
> By default EclipseLink opens a new connection to the database and lazily fetches the
> I could not find a possibility to change this behavior.
> *Hibernate*
> By default Hibernate throws LazyInitializationException.
> Since Version 4.1.6 there is a configuration parameter called “hibernate.enable_lazy_load_no_trans”.
> If set to true hibernate opens a read only session to the database and lazily fetches
the relations. (Same as eclipselink does)
> This parameter is not mentioned in the official hibernate documentation. I found it by
> So 3 Vendors 3 different behaviors and no possibility to configure a behavior that is
support on all providers.
> I just want to say that I do not prefer a specific solution. All 3 solutions have their
advantages and disadvantages. I do think however that this topic should be addressed by the
JPA specification and that a there should be a mandatory behavior in the future.
> But for now could you (the jpa vendors) speak to another and agree on a common denominator?
For me as developer it would enough if I could configure this behavior on each jpa provider
with a vendor specific property. Important is only that there is one solution that is supported
by each provider.
> Thanks for your time!

This message was sent by Atlassian JIRA

View raw message