2
* Hibernate, Relational Persistence for Idiomatic Java
4
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
5
* indicated by the @author tags or express copyright attribution
6
* statements applied by the authors. All third-party contributions are
7
* distributed under license by Red Hat Middleware LLC.
9
* This copyrighted material is made available to anyone wishing to use, modify,
10
* copy, or redistribute it subject to the terms and conditions of the GNU
11
* Lesser General Public License, as published by the Free Software Foundation.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
18
* You should have received a copy of the GNU Lesser General Public License
19
* along with this distribution; if not, write to:
20
* Free Software Foundation, Inc.
21
* 51 Franklin Street, Fifth Floor
22
* Boston, MA 02110-1301 USA
25
package org.hibernate.param;
27
import org.hibernate.engine.QueryParameters;
28
import org.hibernate.engine.SessionImplementor;
29
import org.hibernate.engine.TypedValue;
31
import java.sql.PreparedStatement;
32
import java.sql.SQLException;
35
* Parameter bind specification for an explicit named parameter.
37
* @author Steve Ebersole
39
public class NamedParameterSpecification extends AbstractExplicitParameterSpecification implements ParameterSpecification {
40
private final String name;
43
* Constructs a named parameter bind specification.
45
* @param sourceLine See {@link #getSourceLine()}
46
* @param sourceColumn See {@link #getSourceColumn()}
47
* @param name The named parameter name.
49
public NamedParameterSpecification(int sourceLine, int sourceColumn, String name) {
50
super( sourceLine, sourceColumn );
55
* Bind the appropriate value into the given statement at the specified position.
57
* @param statement The statement into which the value should be bound.
58
* @param qp The defined values for the current query execution.
59
* @param session The session against which the current execution is occuring.
60
* @param position The position from which to start binding value(s).
62
* @return The number of sql bind positions "eaten" by this bind operation.
64
public int bind(PreparedStatement statement, QueryParameters qp, SessionImplementor session, int position)
66
TypedValue typedValue = ( TypedValue ) qp.getNamedParameters().get( name );
67
typedValue.getType().nullSafeSet( statement, typedValue.getValue(), position, session );
68
return typedValue.getType().getColumnSpan( session.getFactory() );
74
public String renderDisplayInfo() {
75
return "name=" + name + ", expectedType=" + getExpectedType();
79
* Getter for property 'name'.
81
* @return Value for property 'name'.
83
public String getName() {