~raginggoblin/infolog/infolog

« back to all changes in this revision

Viewing changes to InfologServer/lib/hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/param/NamedParameterSpecification.java

  • Committer: Raging Goblin
  • Date: 2013-11-16 16:51:32 UTC
  • Revision ID: raging_goblin-20131116165132-weujnptzc88uy4ah
Mavenized the project, now using shared project InfologSync

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Hibernate, Relational Persistence for Idiomatic Java
3
 
 *
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.
8
 
 *
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.
12
 
 *
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
16
 
 * for more details.
17
 
 *
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
23
 
 *
24
 
 */
25
 
package org.hibernate.param;
26
 
 
27
 
import org.hibernate.engine.QueryParameters;
28
 
import org.hibernate.engine.SessionImplementor;
29
 
import org.hibernate.engine.TypedValue;
30
 
 
31
 
import java.sql.PreparedStatement;
32
 
import java.sql.SQLException;
33
 
 
34
 
/**
35
 
 * Parameter bind specification for an explicit named parameter.
36
 
 *
37
 
 * @author Steve Ebersole
38
 
 */
39
 
public class NamedParameterSpecification extends AbstractExplicitParameterSpecification implements ParameterSpecification {
40
 
        private final String name;
41
 
 
42
 
        /**
43
 
         * Constructs a named parameter bind specification.
44
 
         *
45
 
         * @param sourceLine See {@link #getSourceLine()}
46
 
         * @param sourceColumn See {@link #getSourceColumn()} 
47
 
         * @param name The named parameter name.
48
 
         */
49
 
        public NamedParameterSpecification(int sourceLine, int sourceColumn, String name) {
50
 
                super( sourceLine, sourceColumn );
51
 
                this.name = name;
52
 
        }
53
 
 
54
 
        /**
55
 
         * Bind the appropriate value into the given statement at the specified position.
56
 
         *
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).
61
 
         *
62
 
         * @return The number of sql bind positions "eaten" by this bind operation.
63
 
         */
64
 
        public int bind(PreparedStatement statement, QueryParameters qp, SessionImplementor session, int position)
65
 
                throws SQLException {
66
 
                TypedValue typedValue = ( TypedValue ) qp.getNamedParameters().get( name );
67
 
                typedValue.getType().nullSafeSet( statement, typedValue.getValue(), position, session );
68
 
                return typedValue.getType().getColumnSpan( session.getFactory() );
69
 
        }
70
 
 
71
 
        /**
72
 
         * {@inheritDoc}
73
 
         */
74
 
        public String renderDisplayInfo() {
75
 
                return "name=" + name + ", expectedType=" + getExpectedType();
76
 
        }
77
 
 
78
 
        /**
79
 
         * Getter for property 'name'.
80
 
         *
81
 
         * @return Value for property 'name'.
82
 
         */
83
 
        public String getName() {
84
 
                return name;
85
 
        }
86
 
}