UnitOfWork.unregisterObject does not work
The unit of work does not unregister the object.Toplink version is 9.0.3
It tries to insert the unregistered object also.
The scenario is as follows .
1) acquire unit of work
2) register objects
3) One of the registered objects has a attribute that is mapped to a db field varchar(40) but the value in the object is of length 100 .So oracle will throw an exception
4) invoke commitAndResumeOnFailure() on the unit of work
5) catch the exception
6) unregister the problem causing clone.
7) call commit() again.
The unitofwork again tries to insert the unregistered object and fails.
Am I doing some thing wrong.
Code snippet
UnitOfWork uow=server.acquireUnitOfWork();
uow.registerObject(obj1);
obj2Clone=uow.registerObject(obj2); //This object has a attribute that is too long so oracle will throw ORA-01401 exception
try
{
uow.commitAndResumeOnFailure();
}
catch(Exception e)
{
//Since i know which object is causing the problem I unregister that object
// in the actual case i get the query and find the object that is causing the problem.
uow.unregisterObject(obj2Clone);
}
try
{
uow.commit();
}
catch(Exception e)
{
e.printStackTrace();
//Exception thrown ,b'cos the uow tries to insert the obj2( which was already unregistered)and fails.
}