Sunday 8 May 2016

identifier of an instance of Address was altered from 5 to 4 (org.hibernate.HibernateException:)

I Had Assigned The Value To The  Parent's Child Object Id as
Student studentObj=new Student();
StudentDAO daoStudent=new StudentDAO();

studentObj=daoStudent.LoadById(studentBE.StudentId);

studentObj.Address.AddressId=studentBE.AddressId;

Then I Had Got The Exception "Identifier Of An Instance Of Address Was Altered From 5 to 4".
An NHibernateException.


Solution:-
-----------

By Creating A New Object Of Address With The Given Id And Replacing The Address Object Associated With Object Student -- as below:

studentObj.Address=new Address(){AddressId=studentBE.AddressId};

1 comment :

  1. Please let me know the complete solution and i did not catch your concept properly. So,Please update me the complete solution.

    ReplyDelete

Note: only a member of this blog may post a comment.