package org.beigesoft.persistable;

/*
 * Beigesoft ™
 *
 * Licensed under the Apache License, Version 2.0
 *
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 */

import org.beigesoft.model.AEditable;

/**
 * <p>Base abstraction persistable model.
 * For improve performance purpose all ID is
 * triple of autogenerated explicit ID Long type
 * and two implicit(there is no database constraints for them)
 * ID for replication - int(DATABASE_NUMBER)+Long(ID FOREIGN)</p>
 *
 * @author Yury Demidenko
 */
public abstract class APersistableBase extends AEditable
    implements IPersistableBase {

  /**
   * <p>Database column name for ID.</p>
   **/
  public static final String ID_NAME = "id";

  /**
   * <p>Database column name for ID of database of birth.</p>
   **/
  public static final String ID_DATABASE_BIRTH_NAME = "idDatabaseBirth";

  /**
   * <p>Database column name for ID birth.</p>
   **/
  public static final String ID_BIRTH_NAME = "idBirth";

  /**
   * <p>Fast explicit, usable ID of type Long.</p>
   **/
  private Long itsId;

  /**
   * <p>Implicit(there is no database constraints for it)
   * ID database where Entity was born.
   * For replication purpose. Not NULL.</p>
   **/
  private Integer idDatabaseBirth;

  /**
   * <p>Implicit(there is no database constraints for it)
   * ID of this Entity from database where it was born.
   * For replication purpose. NULL if it was born in current database.</p>
   **/
  private Long idBirth;

  /**
   * <p>Geter for id.</p>
   * @return Long
   **/
  @Override
  public final Long getItsId() {
    return this.itsId;
  }

  /**
   * <p>Setter for id.</p>
   * @param pId reference/value
   **/
  @Override
  public final void setItsId(final Long pId) {
    this.itsId = pId;
  }

  /**
   * <p>Geter for idDatabaseBirth.</p>
   * @return Integer
   **/
  @Override
  public final Integer getIdDatabaseBirth() {
    return this.idDatabaseBirth;
  }

  /**
   * <p>Setter for idDatabaseBirth.</p>
   * @param pIdDatabaseBirth reference
   **/
  @Override
  public final void setIdDatabaseBirth(final Integer pIdDatabaseBirth) {
    this.idDatabaseBirth = pIdDatabaseBirth;
  }

  /**
   * <p>Geter for idBirth.</p>
   * @return Long
   **/
  @Override
  public final Long getIdBirth() {
    return this.idBirth;
  }

  /**
   * <p>Setter for idBirth.</p>
   * @param pIdBirth reference
   **/
  @Override
  public final void setIdBirth(final Long pIdBirth) {
    this.idBirth = pIdBirth;
  }
}
