This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 100
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
vShyam Sundar
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 100
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic