• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Lazy loading in JPA

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a question about lazy loading...
I have the following relationship
1 Book has 0..* Reviews.

Scenario is
User searches for books. And then clicks on the book of interest. The system should display all the Reviews for the books.

I am using JPA and I have modelled my Book class to have a List<Review> objects.
I have annotated Reviews as a lazy load.

Now when user searches for books, I use a named query for searching the books. As per my understanding of lazy load, the reviews will not be loaded.
Now these Book entities are serialized and passed to the presentation tier and displayed using jsp. Once the user clicks the book of interest I want to load the reviews for the book.
Will the reviews be loaded if I refer the member ? or Do i have to use the EM to get the reviews using named queries ?

Thanks
Ashwin
 
author
Posts: 580
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ashwin,

What is your persistence provider?

Regards,
Reza
 
Ashwin Pai
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Reza Rahman:
Ashwin,

What is your persistence provider?

Regards,
Reza



Hi Reza,
I am in the process of creating class diagrams & sequence diagrams for SCEA assignment. I was not sure if lazy loading is implemented differently by different vendors!!! I would like to design something which is not provider dependent..if thats why raised the question!!
So would it make sence to make the reference to Reviews transient and have it loaded through named queries ?

Aprreciate your time!!

Thanks
Ashwin
 
Reza Rahman
author
Posts: 580
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ashwin,

Lazy loading behavior outside an active transaction is currently vendor dependent.

Regards,
Reza
 
Of course, I found a very beautiful couch. Definitely. And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic