Hibernate StalestateException problem
I am working on a webapplication where we are using Hibernate for persisting object in the database. Here is the problem we will get an XML from third party and we need to persist this data in to the database.we can get updated XML for the same entity at later time so we need to update all records but since we getting updated XML from third party so no way they can provide us UUID for that entity. So we are using following approach check if the object is already in the database (XML have a unique value as entityid) if object is there delete the record and than save it as new object (Kind of replace mode) if object is not in the databse simple save it.
now here we are facing a serious issue.if i save the object and than in the second call we sent an updated request with object containing updated record hibernate is updating this object UUID with the object saved in the previous transcation.
Now it is able to delete the object but when we try to save the object it throwing stalestate exception since hib开发者_开发知识库ernate has already set the UUID for this object.
We tried to use update method but this will work till the context is same if at later stage we try to update the object than it will complain about the identifier property since in that case that will be null.
can any one help me out how to achieve this since it seems an issue with the context and hibernate internal session management.
Thanks in advance Umesh
Problem solved!! it was related to spring configuration and hibernate was working fine.
精彩评论