I am trying to execute merge(entity)using eclipselink, and I would like to point to eclipse if it will be an update or insert, so it does not need to execute the initial select request. Thanks to the progress made in this matter , I have the following:
UnitOfWorkImpl uow = (UnitOfWorkImpl) ((EntityManagerImpl) em.getDelegate()).getUnitOfWork();
if (dbObj.isInDB())
{
uow.updateObject(dbObj);
}
else
{
uow.insertObject(dbObj);
}
code>
However, I get the following:
org.eclipse.persistence.exceptions.QueryException: Exception Description: Objects cannot be written during a UnitOfWork, they must be registered. Query: UpdateObjectQuery
Am I approaching this in the right way? If so, how can I fix the error?
thanks
source
share