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

io.ebeaninternal.server.persist.dmlbind.BindableDiscriminator Maven / Gradle / Ivy

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

import io.ebean.bean.EntityBean;
import io.ebeaninternal.server.core.PersistRequestBean;
import io.ebeaninternal.server.deploy.InheritInfo;
import io.ebeaninternal.server.persist.dml.GenerateDmlRequest;

import javax.persistence.PersistenceException;
import java.sql.SQLException;
import java.util.List;

/**
 * Bindable for inserting a discriminator value.
 */
public class BindableDiscriminator implements Bindable {

  private final String columnName;
  private final Object discValue;
  private final int sqlType;

  public BindableDiscriminator(InheritInfo inheritInfo) {
    this.columnName = inheritInfo.getDiscriminatorColumn();
    this.discValue = inheritInfo.getDiscriminatorValue();
    this.sqlType = inheritInfo.getDiscriminatorType();
  }

  @Override
  public String toString() {
    return columnName + " = " + discValue;
  }

  @Override
  public boolean isDraftOnly() {
    return false;
  }

  @Override
  public void addToUpdate(PersistRequestBean request, List list) {
    throw new PersistenceException("Never called (only for inserts)");
  }

  @Override
  public void dmlAppend(GenerateDmlRequest request) {
    request.appendColumn(columnName);
  }

  @Override
  public void dmlBind(BindableRequest bindRequest, EntityBean bean) throws SQLException {

    bindRequest.bind(discValue, sqlType);
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy