Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Session 'Magic' newb Question

Well I don't see how you could not get an error when working with a
null EM/EMF/DAO...but I'll assume I'm just following you wrong.

As per LazyInitializationException I've never seen it.

./tch



On Fri, Aug 28, 2009 at 7:20 PM, JimOR<jimorourke@xxxxxxxxxxxxxxxx> wrote:
>
> In the course of the migrating a Toplink JPA RESOURCE_LOCAL DAO project to
> EclipseLink, I've hit a fair share of n+1 @ManyToOne(EAGER) DB hits that I'd
> like to optimize. As an example; Order.class has 1:n LAZY LineItem which has
> EAGER n:1 Product.  So, as you would expect, each access of a LineItem is
> generating a DB query for a single Product.
>
> So I set LineItem.product to FetchType.LAZY, and added some
> getLinesAndProduct(...) to our OrderDAO API using combinations of
> javax.Persistence.Query.setHint(QueryHints.BATCH,...) and
> (QueryHints.FETCH,...) to review the generated queries, and wrote a tescase
> hoping to generate an error accessing something like
> lineitem.getProduct().getVendor() using the original DAO getLines() method.
>
> To my surprise, no testcase errors occur.  Any order's lineitem's product's
> vendor name is magically returned (with some trips to the DB) when
> requested, regardless of whether I set the dao=null, close/nullify the
> EntityManager and/or EMFactory.  The only way I can produce an error is to
> serialize and deserialize the list.
>
> My persistence.xml properties contains only jdbc connection stuff, so
> everything else is defaults, and our JPA Entities are statically weaved
> (woven?) using ant.  We have a static DAOFactory that returns an
> implementation of the requested Interface, and each implementation extends
> an abstract CommonCRUD class that, among other things, supplies an
> EntityManager created from a singleton EntityManagerFactoryProvider class.
> Everything in the project (except the ant weaving and my QueryHints stuff)
> is pure javax.persistence API.
>
> Is my deep seated fear of 'LazyInitializationException' been rendered moot
> by JPA, or RESOURCE_LOCAL, or EclipseLink sessions, or is this simply a
> poorly written testcase?
>
> Any pointers are appreciated.
>
> Jim
>
>
>
> --
> View this message in context: http://www.nabble.com/Session-%27Magic%27-newb-Question-tp25198387p25198387.html
> Sent from the EclipseLink - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>


Back to the top