OK, thanks. You guys are just being nice and going above and beyond what's
required in the spec. :-)
Jon
----- Original Message -----
From: "Gordon Yorke" <gordon.yorke_at_oracle.com>
To: <persistence_at_glassfish.dev.java.net>
Sent: Tuesday, January 16, 2007 2:55 PM
Subject: RE: Lazy load of collection works even after EntityManager is
closed?
> Hello Jon,
> It works because TopLink is providing extended functionality.
> Accessing lazy attribute post EM.close() is a valid and often used
> use-case that we chose to support.
> --Gordon
>
> -----Original Message-----
> From: Jon Miller [mailto:jemiller_at_uchicago.edu]
> Sent: Tuesday, January 16, 2007 3:47 PM
> To: Glassfish Persistence List
> Subject: Lazy load of collection works even after EntityManager is
> closed?
>
>
> Another difference that I noticed between TopLink and Hibernate is that
> the
> following code works with TopLink but not with Hibernate. In the following
> example, I have a Location object which has a list of Schedule objects.
> The
> list of schedules isn't being iterated over until after the EntityManager
> has been closed. In Hibernate, an exception is thrown, but, it somehow
> still
> works with TopLink. How can that be?
>
> public void testLazyLoadAfterEntityManagerClosed() {
> EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("Common");
> EntityManager em = emf.createEntityManager();
> Location l = em.find(Location.class, 117);
> logger.info("l = " + l);
> em.close();
> for(Schedule s : l.getSchedules()) {
> logger.info("s = " + s);
> }
> emf.close();
> }
>
> Jon
>