All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.ebeaninternal.server.persist.MergeContext Maven / Gradle / Ivy

There is a newer version: 15.8.0
Show newest version
package io.ebeaninternal.server.persist;

import io.ebean.bean.EntityBean;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.api.SpiTransaction;

import java.util.ArrayList;
import java.util.List;

/**
 * Context used for merge processing.
 */
final class MergeContext {

  private final SpiEbeanServer server;

  private final SpiTransaction transaction;

  private final List deleteBeans = new ArrayList<>();

  private final boolean clientGeneratedIds;

  MergeContext(SpiEbeanServer server, SpiTransaction transaction, boolean clientGeneratedIds) {
    this.server = server;
    this.transaction = transaction;
    this.clientGeneratedIds = clientGeneratedIds;
  }

  public SpiEbeanServer getServer() {
    return server;
  }

  public SpiTransaction getTransaction() {
    return transaction;
  }

  /**
   * Add to the list of beans to delete.
   */
  void addDelete(EntityBean deleteBean) {
    deleteBeans.add(deleteBean);
  }

  /**
   * Return true if Ids must be checked against the DB.
   */
  boolean isClientGeneratedIds() {
    return clientGeneratedIds;
  }

  /**
   * Check if the Id / bean exists in the database.
   */
  boolean idExists(Class beanType, Object beanId) {
    return server.exists(beanType, beanId, transaction);
  }

  /**
   * Return the list of beans to delete.
   */
  List getDeletedBeans() {
    return deleteBeans;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy