2
我想使用的EclipseLink執行merge(entity)
,我想指出日食是否會被更新或插入,所以它並沒有進行初始選擇查詢。由於在this question取得的進展,我有以下幾點:的EclipseLink合併(),而初始SELECT
UnitOfWorkImpl uow = (UnitOfWorkImpl) ((EntityManagerImpl) em.getDelegate()).getUnitOfWork();
if (dbObj.isInDB())
{
uow.updateObject(dbObj);
}
else
{
uow.insertObject(dbObj);
}
不過,我得到以下幾點:
org.eclipse.persistence.exceptions.QueryException: Exception Description: Objects cannot be written during a UnitOfWork, they must be registered. Query: UpdateObjectQuery
難道我這個接近正確的方法是什麼?如果是這樣,我該如何糾正錯誤?
感謝