aspose file tools*
The moose likes JBoss/WildFly and the fly likes LazyLoadException on hibernate/JPA entity manager for huge volume of data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "LazyLoadException on hibernate/JPA entity manager for huge volume of data" Watch "LazyLoadException on hibernate/JPA entity manager for huge volume of data" New topic
Author

LazyLoadException on hibernate/JPA entity manager for huge volume of data

vShyam Sundar
Ranch Hand

Joined: Oct 13, 2010
Posts: 60
Hi,
I am using Jboss 5.1 version with hibernate/JPA to communicate with DB.
In one of my module I am facing Lazy Load exception. Below is the trace for that.

2013-06-05 06:19:20,221 ERROR [org.hibernate.LazyInitializationException] (http-127.0.0.1-8080-1) could not initialize proxy - no Session
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:132)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:174)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
at com.ep.ff.entity.setup.Batch_$$_javassist_67.getName(Batch_$$_javassist_67.java)
at com.ep.ff.transfer.send.flexreport.builder.FlexLedgerReportBuilder.buildFlexDetailRecord(FlexLedgerReportBuilder.java:124)

This is happening only when I am trying to load some huge set of data ( approx 100000 no of record which took around 30 min to load from DB) from DB and iterating the list of entities to access some data (ManyToOne relationship which is lazily loaded initially) out of entity object. I am not getting this error when I am trying for smaller set of record (10000 to 50000) which is fetched in very less time.

I tried reconnect the Entitymanager before access the attribute of entity object in the following way. But there is no luck still.



Is there anyone who face similar issue or have any idea/clue about the issue, Kindly let me know. Any kind of help is appreciated.

Thanks,
Shyam Veda
lokesh sree
Ranch Hand

Joined: Oct 27, 2009
Posts: 100

Hi,
Just a random thought.. I believe you might be doing all this data fetch inside a transaction. In that case, it's working looking at it from a transaction time-out perspective as well. By default, the Transactions have a 5min timeout values. You can try increasing the timeout values and verify your large data loads.


Lokesh
( SCBCD 5, CCENT, SCJP 5 )
vShyam Sundar
Ranch Hand

Joined: Oct 13, 2010
Posts: 60
Hi,
Thanks for your reply.
I have alredy tried setting "transactionTimeout" value to "999999" in transaction-jboss-bean.xml also. But it still didn't work out.

And one more thing, when I am trying to load the lazy data in the Selector class(where I am getting entire entity list from DB) by iterating the entity list, I am able to load the lazy data. But when I am coming out of the selector class and going to a builder class ( used for building TO object out of entity object) with the entity list, there I am getting LazyLoadException.

Is it something to do with Bean life of EJB ? Please suggest.

Note - I am using EJB as well.

Thanks,
Jyoti
lokesh sree
Ranch Hand

Joined: Oct 27, 2009
Posts: 100

In that case, the only reason i can think of is - The Selector class is inside the scope of transaction. So, when you are trying to lazily fetch the data, it would work fine. But, when you go to the builder class, the transaction would scope would have ended, the hibernate session gets closed. So, if you now try accessing the data which is supposed to be fetched lazily, it will not work.
I am not much aware of hibernate session internals. So, I cannot provide more inputs here.
 
 
subject: LazyLoadException on hibernate/JPA entity manager for huge volume of data