/** * Perform parameter binding * * @param st The statement to bind parameters to * @param queryParameters The parameters * @param start The initial bind position * @param source The named parameter source, for resolving the locations of named parameters * @param session The session * * @return The next bind position after the last position we bound here. * * @throws SQLException Indicates a problem calling JDBC bind methods * @throws HibernateException Indicates a problem access bind values. */ public static int bindQueryParameters( final PreparedStatement st, final QueryParameters queryParameters, final int start, final NamedParameterSource source, SessionImplementor session) throws SQLException, HibernateException { int col = start; col += bindPositionalParameters( st, queryParameters, col, session ); col += bindNamedParameters( st, queryParameters, col, source, session ); return col; }
private static int bindPositionalParameters( final PreparedStatement st, final QueryParameters queryParameters, final int start, final SessionImplementor session) throws SQLException, HibernateException { return bindPositionalParameters( st, queryParameters.getPositionalParameterValues(), queryParameters.getPositionalParameterTypes(), start, session ); }
private static int bindNamedParameters( final PreparedStatement ps, final Map namedParams, final int start, final NamedParameterSource source, final SessionImplementor session) throws SQLException, HibernateException { if ( namedParams != null ) { final boolean debugEnabled = LOG.isDebugEnabled(); // assumes that types are all of span 1 final Iterator iter = namedParams.entrySet().iterator(); int result = 0; while ( iter.hasNext() ) { final Map.Entry e = (Map.Entry) iter.next(); final String name = (String) e.getKey(); final TypedValue typedVal = (TypedValue) e.getValue(); final int[] locations = source.getNamedParameterLocations( name ); for ( int location : locations ) { if ( debugEnabled ) { LOG.debugf( "bindNamedParameters() %s -> %s [%s]", typedVal.getValue(), name, location + start ); } typedVal.getType().nullSafeSet( ps, typedVal.getValue(), location + start, session ); } result += locations.length; } return result;
public static int bindPositionalParameters( final PreparedStatement st, final QueryParameters queryParameters, final int start, final SessionImplementor session) throws SQLException, HibernateException { return bindPositionalParameters( st, queryParameters.getPositionalParameterValues(), queryParameters.getPositionalParameterTypes(), start, session ); }
public static int bindNamedParameters( final PreparedStatement ps, final Map namedParams, final int start, final NamedParameterSource source, final SessionImplementor session) throws SQLException, HibernateException { if ( namedParams != null ) { // assumes that types are all of span 1 Iterator iter = namedParams.entrySet().iterator(); int result = 0; while ( iter.hasNext() ) { Map.Entry e = ( Map.Entry ) iter.next(); String name = ( String ) e.getKey(); TypedValue typedval = (TypedValue) e.getValue(); int[] locations = source.getNamedParameterLocations( name ); for ( int i = 0; i < locations.length; i++ ) { if ( LOG.isDebugEnabled() ) { LOG.debugf("bindNamedParameters() %s -> %s [%s]", typedval.getValue(), name, locations[i] + start); } typedval.getType().nullSafeSet( ps, typedval.getValue(), locations[i] + start, session ); } result += locations.length; } return result; } return 0; } }
public static int bindQueryParameters( final PreparedStatement st, final QueryParameters queryParameters, final int start, final NamedParameterSource source, SessionImplementor session) throws SQLException, HibernateException { int col = start; col += bindPositionalParameters( st, queryParameters, col, session ); col += bindNamedParameters( st, queryParameters, col, source, session ); return col; }
public static int bindPositionalParameters( final PreparedStatement st, final QueryParameters queryParameters, final int start, final SessionImplementor session) throws SQLException, HibernateException { return bindPositionalParameters( st, queryParameters.getPositionalParameterValues(), queryParameters.getPositionalParameterTypes(), start, session ); }
public static int bindNamedParameters( final PreparedStatement ps, final Map namedParams, final int start, final NamedParameterSource source, final SessionImplementor session) throws SQLException, HibernateException { if ( namedParams != null ) { // assumes that types are all of span 1 Iterator iter = namedParams.entrySet().iterator(); int result = 0; while ( iter.hasNext() ) { Map.Entry e = ( Map.Entry ) iter.next(); String name = ( String ) e.getKey(); TypedValue typedval = (TypedValue) e.getValue(); int[] locations = source.getNamedParameterLocations( name ); for ( int i = 0; i < locations.length; i++ ) { if ( LOG.isDebugEnabled() ) { LOG.debugf("bindNamedParameters() %s -> %s [%s]", typedval.getValue(), name, locations[i] + start); } typedval.getType().nullSafeSet( ps, typedval.getValue(), locations[i] + start, session ); } result += locations.length; } return result; } return 0; } }
public static int bindQueryParameters( final PreparedStatement st, final QueryParameters queryParameters, final int start, final NamedParameterSource source, SessionImplementor session) throws SQLException, HibernateException { int col = start; col += bindPositionalParameters( st, queryParameters, col, session ); col += bindNamedParameters( st, queryParameters, col, source, session ); return col; }