You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Caused by: com.impetus.kundera.proxy.LazyInitializationException: Unable to load Proxy Collection. This happens when you access a lazily loaded proxy collection in an entity after entity manager has been closed.
at com.impetus.kundera.proxy.collection.AbstractProxyBase.eagerlyLoadDataCollection(AbstractProxyBase.java:111) ~[kundera-core-3.12.jar:na]
at com.impetus.kundera.proxy.collection.AbstractProxyCollection.iterator(AbstractProxyCollection.java:221) ~[kundera-core-3.12.jar:na]
at com.impetus.kundera.proxy.collection.ProxySet.iterator(ProxySet.java:118) ~[kundera-core-3.12.jar:na]
at it.thisone.iotter.persistence.service.EmptyDbInitializator.checkDb(EmptyDbInitializator.java:126) ~[vaadin8-iotter-backend-3.0-SNAPSHOT.jar:na]
at it.thisone.iotter.persistence.service.EmptyDbInitializator.afterPropertiesSet(EmptyDbInitializator.java:111) ~[vaadin8-iotter-backend-3.0-SNAPSHOT.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
... 21 common frames omitted
I got the exception using a spring service.
Service retrieves a list of TUser and it tries to read a collection of TRole (annotated with FetchType.LAZY) associated to each TUser
Exception is clear and it does not happen if I execute the same operations with an EntityManager directly.
I do not think it is a problem of spring service since it is working correctly with EclipseLink
Looking at logs, entitymanager is close after retrieving list of TUser consequently it is not possible to retrieve a FetchType.LAZY collection
15:23:40.659 [localhost-startStop-1] DEBUG c.i.k.persistence.EntityManagerImpl - Created EntityManager for persistence unit : cassandra_pu
15:23:40.985 [localhost-startStop-1] INFO com.impetus.kundera.query.QueryImpl - On getResultList() executing query: select be from TUser be
15:23:40.985 [localhost-startStop-1] DEBUG c.i.client.cassandra.query.CassQuery - Populating entities for Cassandra query select be from TUser be.
15:24:24.399 [localhost-startStop-1] DEBUG o.s.o.jpa.EntityManagerFactoryUtils - Closing JPA EntityManager
If I try to reattach EntityManager to a TUser entity with a merge and retrieve lazy collection, I get a similar exception
Please help me to understand what I'm doing wrong
I'm using @config with
@EnableAspectJAutoProxy(proxyTargetClass=true)
and @PersistenceContext to inject entitymanager
I got the exception using a spring service.
Service retrieves a list of TUser and it tries to read a collection of TRole (annotated with FetchType.LAZY) associated to each TUser
Exception is clear and it does not happen if I execute the same operations with an EntityManager directly.
I do not think it is a problem of spring service since it is working correctly with EclipseLink
Looking at logs, entitymanager is close after retrieving list of TUser consequently it is not possible to retrieve a FetchType.LAZY collection
If I try to reattach EntityManager to a TUser entity with a merge and retrieve lazy collection, I get a similar exception
Please help me to understand what I'm doing wrong
I'm using @config with
@EnableAspectJAutoProxy(proxyTargetClass=true)
and @PersistenceContext to inject entitymanager
classes
persistence.xml
maven dependencies
The text was updated successfully, but these errors were encountered: