Ejemplo n.º 1
0
  void makePersistent(PersistenceBroker pb, int txNumber) throws SQLException, LookupException {
    // store new objects
    if (newObjs != null) {
      for (Object obj : newObjs) {
        pb.store(obj, ObjectModificationDefaultImpl.INSERT);
      }
    }

    boolean foundOptimisticException = false;

    // update objects
    if (objsToStore != null) {
      for (Object obj : objsToStore) {
        try {
          pb.store(obj, ObjectModificationDefaultImpl.UPDATE);
        } catch (OptimisticLockException ole) {
          pb.removeFromCache(obj);
          foundOptimisticException = true;
        }
      }
    }

    if (foundOptimisticException) {
      throw new jvstm.CommitException();
    }

    // delete objects
    if (objsToDelete != null) {
      for (Object obj : objsToDelete) {
        pb.delete(obj);
      }
    }

    // write m-to-n tuples
    if (mToNTuples != null) {
      for (RelationTupleInfo info : mToNTuples.values()) {
        updateMtoNRelation(pb, info);
      }
    }

    // write change logs
    Connection conn = pb.serviceConnectionManager().getConnection();
    writeAttrChangeLogs(conn, txNumber);
  }