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

io.ebeaninternal.server.persist.dmlbind.BindableAssocOneGeneratedInsert 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.BeanPropertyAssocOne;
import io.ebeaninternal.server.deploy.generatedproperty.GeneratedProperty;

import java.sql.SQLException;
import java.util.List;

/**
 * Bindable for generated ManyToOne - likely 'who created'.
 */
class BindableAssocOneGeneratedInsert extends BindableAssocOne {

  private final GeneratedProperty generatedProperty;

  BindableAssocOneGeneratedInsert(BeanPropertyAssocOne assocOne) {
    super(assocOne);
    this.generatedProperty = assocOne.getGeneratedProperty();
  }

  @Override
  public void addToUpdate(PersistRequestBean request, List list) {
    throw new RuntimeException("never called");
  }

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

    Object objectValue = generatedProperty.getInsertValue(assocOne, bean, request.now());
    EntityBean generatedValue = castToEntityBean(objectValue);
    assocOne.setValue(bean, generatedValue);
    registerDeferred(request, bean, generatedValue);
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy