Save and update an object using EJB 2.0 and JPA (Toplink) issues

In my client application, I want to call the repository and update one EJB method instead of two calls to two methods. I created an EJB method, forcing it to call two other EJB methods and it looks simple:

 public ZippedObjectWrapper saveAndRefresh(final Item p_item) {
    Long itemSavedId= save(p_item);
    return refresh(itemSavedId);
  }

The problem is that Toplink, which does not allow me to read data, but generates an exception in terms of updating:

Exception [TOPLINK-7123] Exception Description: successful writeChanges () is called on this UnitOfWork. Since the commit process has been started but not yet completed, the only supported operations now are commit, commitAndResume, release, any object level query, or SQLCall. The executeQuery (ObjectLevelReadQuery) operation is currently prohibited.

Any suggestions?

EDIT: Modified method signatures.

+3
source share
2 answers

The problem is Toplink, especially how it handles database operations in the version we are using. There is a partial solution when you extend the Toplink class or, better, update Toplink :)

0
source

Not sure what your save () method does, but I assume you are calling writeChanges () on your UnitOfWork. Requests were not resolved after writeChanges () in the version you are using. Removing the writeChanges () problem should fix the problem.

EclipseLink JPA, flush() . RepeatableWriteUnitOfWork UnitOfWork, writeChanges() .

+1

All Articles