1
// $Id: PositionalParameterSpecification.java 8513 2005-11-02 18:47:40Z steveebersole $
2
package org.hibernate.param;
4
import org.hibernate.engine.QueryParameters;
5
import org.hibernate.engine.SessionImplementor;
6
import org.hibernate.type.Type;
8
import java.sql.PreparedStatement;
9
import java.sql.SQLException;
12
* Relates to an explicit query positional (or ordinal) parameter.
14
* @author Steve Ebersole
16
public class PositionalParameterSpecification extends AbstractExplicitParameterSpecification implements ParameterSpecification {
18
private final int hqlPosition;
20
public PositionalParameterSpecification(int sourceLine, int sourceColumn, int hqlPosition) {
21
super( sourceLine, sourceColumn );
22
this.hqlPosition = hqlPosition;
26
* Bind the appropriate value into the given statement at the specified position.
28
* @param statement The statement into which the value should be bound.
29
* @param qp The defined values for the current query execution.
30
* @param session The session against which the current execution is occuring.
31
* @param position The position from which to start binding value(s).
33
* @return The number of sql bind positions "eaten" by this bind operation.
35
public int bind(PreparedStatement statement, QueryParameters qp, SessionImplementor session, int position) throws SQLException {
36
Type type = qp.getPositionalParameterTypes()[hqlPosition];
37
Object value = qp.getPositionalParameterValues()[hqlPosition];
39
type.nullSafeSet( statement, value, position, session );
40
return type.getColumnSpan( session.getFactory() );
43
public String renderDisplayInfo() {
44
return "ordinal=" + hqlPosition + ", expectedType=" + getExpectedType();
47
public int getHqlPosition() {