0

I am using HibernateTemplate in my spring application. when ever I try to call a operation like save, update or delete , then I get this as exception.

Exception in delete in service org.hibernate.LazyInitializationException: could not initialize proxy - no Session

joragupra
  • 692
  • 1
  • 12
  • 23
Akash Goswami
  • 296
  • 3
  • 14

1 Answers1

1

The exception says you are trying to load an lazy collection which of out of session. Meaning you need to initialize the collection object before you use. The initialization should happen either in entity setter method or in DAO class. Initializing in setter method of an entity is not recommended usually since it couples your entity with hibernate framework. So best place is DAO layer. But here I have mentioned just for your reference

try this in your code

public void setInfo(IndentityInfo info)
  {


   Hibernate.initialize(info);     
   this.info = info;

  }

Hope this is helpful!

Balaji Reddy
  • 4,901
  • 3
  • 30
  • 43