Package org.hibernate.engine.spi

Examples of org.hibernate.engine.spi.TypedValue


        if ( isLikeEnabled ) {
          string = matchMode.toMatchString( string );
        }
        value = string;
      }
      list.add( new TypedValue( type, value ) );
    }
  }
View Full Code Here


    if ( CollectionHelper.isEmpty( namedParams ) ) {
      return result;
    }

    for ( String name : namedParams.keySet() ) {
      TypedValue typedValue = namedParams.get( name );
      int columnSpan = typedValue.getType().getColumnSpan( getFactory() );
      int[] locs = getNamedParameterLocs( name );
      for ( int loc : locs ) {
        if ( DEBUG_ENABLED ) {
          LOG.debugf(
              "bindNamedParameters() %s -> %s [%s]",
              typedValue.getValue(),
              name,
              loc + startIndex
          );
        }
        int start = loc * columnSpan + startIndex;
        typedValue.getType().nullSafeSet( statement, typedValue.getValue(), start, session );
      }
      result += locs.length;
    }
    return result;
  }
View Full Code Here

  @Override
  public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
    final TypedValue[] subQueryTypedValues = super.getTypedValues( criteria, criteriaQuery );
    final TypedValue[] result = new TypedValue[subQueryTypedValues.length+1];
    System.arraycopy( subQueryTypedValues, 0, result, 1, subQueryTypedValues.length );
    result[0] = new TypedValue( getTypes()[0], value );
    return result;
  }
View Full Code Here

  public Query setParameter(String name, Object val, Type type) {
    if ( !parameterMetadata.getNamedParameterNames().contains( name ) ) {
      throw new IllegalArgumentException("Parameter " + name + " does not exist as a named parameter in [" + getQueryString() + "]");
    }
    else {
       namedParameters.put( name, new TypedValue( type, val  ) );
       return this;
    }
  }
View Full Code Here

  @Override
  public Query setParameterList(String name, Collection vals, Type type) throws HibernateException {
    if ( !parameterMetadata.getNamedParameterNames().contains( name ) ) {
      throw new IllegalArgumentException("Parameter " + name + " does not exist as a named parameter in [" + getQueryString() + "]");
    }
    namedParameterLists.put( name, new TypedValue( type, vals ) );
    return this;
  }
View Full Code Here

        StringHelper.getFirstNonWhitespaceCharacter( afterPlaceholder ) == ')';

    if ( vals.size() == && isEnclosedInParens ) {
      // short-circuit for performance when only 1 value and the
      // placeholder is already enclosed in parentheses...
      namedParamsCopy.put( name, new TypedValue( type, vals.iterator().next() ) );
      return query;
    }

    StringBuilder list = new StringBuilder( 16 );
    Iterator iter = vals.iterator();
    int i = 0;
    while ( iter.hasNext() ) {
      // Variable 'name' can represent a number or contain digit at the end. Surrounding it with
      // characters to avoid ambiguous definition after concatenating value of 'i' counter.
      String alias = ( isJpaPositionalParam ? 'x' + name : name ) + '_' + i++ + '_';
      if ( namedParamsCopy.put( alias, new TypedValue( type, iter.next() ) ) != null ) {
        throw new HibernateException( "Repeated usage of alias '" + alias + "' while expanding list parameter." );
      }
      list.append( ParserHelper.HQL_VARIABLE_PREFIX ).append( alias );
      if ( iter.hasNext() ) {
        list.append( ", " );
View Full Code Here

      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[] locs = getNamedParameterLocs( name );
        for ( int loc : locs ) {
          LOG.debugf( "bindNamedParameters() %s -> %s [%s]", typedval.getValue(), name, loc + start );
          typedval.getType().nullSafeSet(
              ps,
              typedval.getValue(),
              loc + start,
              session
          );
        }
        result += locs.length;
View Full Code Here

   * @return The number of sql bind positions "eaten" by this bind operation.
   */
  @Override
  public int bind(PreparedStatement statement, QueryParameters qp, SessionImplementor session, int position)
          throws SQLException {
    TypedValue typedValue = qp.getNamedParameters().get( name );
    typedValue.getType().nullSafeSet( statement, typedValue.getValue(), position, session );
    return typedValue.getType().getColumnSpan( session.getFactory() );
  }
View Full Code Here

          final Serializable currentId = ForeignKeys.getEntityIdentifierIfNotUnsaved(
              entityName,
              current,
              session
          );
          currentIds.add( new TypedValue( idType, currentId ) );
        }
      }
    }

    // iterate over the *old* list
    for ( Object old : oldElements ) {
      if ( !currentSaving.contains( old ) ) {
        final Serializable oldId = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, old, session );
        if ( !currentIds.contains( new TypedValue( idType, oldId ) ) ) {
          res.add( old );
        }
      }
    }

View Full Code Here

    );
  }

  @Override
  public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
    return new TypedValue[] { new TypedValue( StandardBasicTypes.INTEGER, size ) };
  }
View Full Code Here

TOP

Related Classes of org.hibernate.engine.spi.TypedValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.