• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is lazyinitializationexception

 
mara thamizhan
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear dudes,
I am having a domain object which has a list of child domains.
In my mapping i've declared lazy=false.
While mapping i am gettting lazyinitialization exception.
What is this and why this exception is thrown and how to fix it.
Regards.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SECOND REQUEST

"arr gem",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted.
[ March 24, 2008: Message edited by: Mark Spritzler ]
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be getting this exception at runtime, right?

Basically, you are calling a getter on your 'associated' or 'many' instances after the transaction has been committed. Once a transaction is closed, or a Session that loaded the one side of the equation, is closed or committed, lazy objects from that relationship can no longer be loaded - the associated instances are really proxies or placeholders for real data, and that data was only accessible during the transaction that loaded the one side.

Don't commit your transaction so early, or you can call the associated objects before the transaction is committed.

Happy Hibernating!

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic