Open Source Repository

Home /hibernate/hibernate-3.2.7.ga | Repository Home



org/hibernate/param/VersionTypeSeedParameterSpecification.java
// $Id: VersionTypeSeedParameterSpecification.java 15240 2008-10-01 19:32:11Z [email protected] $
package org.hibernate.param;

import org.hibernate.engine.QueryParameters;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.type.VersionType;
import org.hibernate.type.Type;
import org.hibernate.param.ParameterSpecification;

import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * Parameter bind specification used for optimisitc lock version seeding (from insert statements).
 *
 @author Steve Ebersole
 */
public class VersionTypeSeedParameterSpecification implements ParameterSpecification {
  private VersionType type;

  /**
   * Constructs a version seed parameter bind specification.
   *
   @param type The version type.
   */
  public VersionTypeSeedParameterSpecification(VersionType type) {
    this.type = type;
  }

  /**
   * {@inheritDoc}
   */
  public int bind(PreparedStatement statement, QueryParameters qp, SessionImplementor session, int position)
          throws SQLException {
    type.nullSafeSetstatement, type.seedsession ), position, session );
    return 1;
  }

  /**
   * {@inheritDoc}
   */
  public Type getExpectedType() {
    return type;
  }

  /**
   * {@inheritDoc}
   */
  public void setExpectedType(Type expectedType) {
    // expected type is intrinsic here...
  }

  /**
   * {@inheritDoc}
   */
  public String renderDisplayInfo() {
    return "version-seed, type=" + type;
  }
}