openjpa-dev mailing list archives

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

    [ https://issues.apache.org/jira/browse/OPENJPA-2483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13932279#comment-13932279
] 

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.


[1]  http://ci.apache.org/projects/openjpa/trunk/docbook/manual.html#ref_guide_detach_graph

> Detached Entities and Lazy Loading behavior breaks portability
> --------------------------------------------------------------
>
>                 Key: OPENJPA-2483
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2483
>             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
loading”
> 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
relations.
> 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
accident.
> 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
(v6.2#6252)

Mime
View raw message