This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes org.hibernate.LazyInitializationException: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "org.hibernate.LazyInitializationException:" Watch "org.hibernate.LazyInitializationException:" New topic


Vas Miriyala
Ranch Hand

Joined: Sep 14, 2009
Posts: 114

Dear all I am getting below error when i perform insert operation between two tables.
Table2:categorycategoryrelation(one to many relationship with category table)
in category table i have a columns id,name and in categorycategoryrelation table i have columns parentcategoryId,childCategoryId and these two id are coming from category table(id)
i am using spring MVC with portlets
this is the error i am getting

In my controller first I am inserting category into category table and then i am adding child to this category.In my Dao I am using SessionFactory.getCurrentSession() for CRUD oprations
can some one tell me how can i solve this

Database tables:

both are pk,fk which are refered to id column in category table
Vas Miriyala
Ranch Hand

Joined: Sep 14, 2009
Posts: 114

I found the solution,its very simple,Moved the logic code from Controller to Service Layer,,worked fine,because from Service Layer we are Doing Transaction
Have you checked out Aspose?
subject: org.hibernate.LazyInitializationException:
It's not a secret anymore!