tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: Rest and lazy loaded JPA 2.0 hibernate entities
Date Mon, 15 Oct 2012 21:41:26 GMT
Hi,

Call e.getRelationship().size() before the end of the tx
Le 15 oct. 2012 22:18, "potgieterdl" <derick.potgieter@gmail.com> a écrit :

> Hi All,
>
> I`m running tomee rest 1.5.0 and have swapped openjpa to hibernate.
> I`m having a issue is my rest service on returning a List<Customer> which
> is
> throwing a lazy load exception :
>
> org.hibernate.LazyInitializationException: could not initialize proxy - no
> Session
>         at
>
> org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:180
>
>
> This happens because the jpa session closes before the object conversion to
> xml/json happens. so it cant load the mapped entities.
>
> I`m looking for suggestions here around possible solutions. The only 1 i
> can
> think of is creating DTO`s and mapping the values to them, but creates alot
> of duplicaiton. Issue is i do need to know the primary key for the mapped
> entity to send through.
>
> Is there any other way that this can be achieved?
>
> Thanks
> Derick
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Rest-and-lazy-loaded-JPA-2-0-hibernate-entities-tp4658042.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message