• 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

org.hibernate.LazyInitializationException:

 
Ranch Hand
Posts: 114
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all I am getting below error when i perform insert operation between two tables.
scenarion:
Table1:Category
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

Category.java


CategoryCategoryRelation.java


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:
Category
id(pk)
name
description

CategoryCategoryRelation
parentCategoryId
childCategoryId
both are pk,fk which are refered to id column in category table
 
Vas Miriyala
Ranch Hand
Posts: 114
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
I hired a bunch of ninjas. The fridge is empty, but I can't find them to tell them the mission.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic