Package org.hibernate.engine

Examples of org.hibernate.engine.TypedValue


  private String expandParameterList(String query, String name, TypedValue typedList, Map namedParamsCopy) {
    Collection vals = (Collection) typedList.getValue();
    Type type = typedList.getType();
    if ( vals.size() == 1 ) {
      // short-circuit for performance...
      namedParamsCopy.put( name, new TypedValue( type, vals.iterator().next(), session.getEntityMode() ) );
      return query;
    }

    StringBuffer list = new StringBuffer( 16 );
    Iterator iter = vals.iterator();
    int i = 0;
    boolean isJpaPositionalParam = parameterMetadata.getNamedParameterDescriptor( name ).isJpaStyle();
    while ( iter.hasNext() ) {
      String alias = ( isJpaPositionalParam ? 'x' + name : name ) + i++ + '_';
      namedParamsCopy.put( alias, new TypedValue( type, iter.next(), session.getEntityMode() ) );
      list.append( ParserHelper.HQL_VARIABLE_PREFIX ).append( alias );
      if ( iter.hasNext() ) {
        list.append( ", " );
      }
    }
View Full Code Here


      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[] locs = getNamedParameterLocs( name );
        for ( int i = 0; i < locs.length; i++ ) {
          if ( log.isDebugEnabled() ) {
            log.debug(
                "bindNamedParameters() " +
                typedval.getValue() + " -> " + name +
                " [" + ( locs[i] + startIndex ) + "]"
              );
          }
          typedval.getType().nullSafeSet( statement, typedval.getValue(), locs[i] + startIndex, session );
        }
        result += locs.length;
      }
      return result;
    }
View Full Code Here

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

      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[] locs = getNamedParameterLocs( name );
        for ( int i = 0; i < locs.length; i++ ) {
          if ( log.isDebugEnabled() ) {
            log.debug(
                "bindNamedParameters() " +
                typedval.getValue() + " -> " + name +
                " [" + ( locs[i] + startIndex ) + "]"
              );
          }
          typedval.getType().nullSafeSet( statement, typedval.getValue(), locs[i] + startIndex, session );
        }
        result += locs.length;
      }
      return result;
    }
View Full Code Here

      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[] locs = getNamedParameterLocs( name );
        for (int i = 0; i < locs.length; i++) {
          if ( log.isDebugEnabled() ) {
            log.debug( "bindNamedParameters() "
                + typedval.getValue() + " -> " + name + " ["
                + (locs[i] + start ) + "]" );
          }
          typedval.getType().nullSafeSet( ps, typedval.getValue(),
              locs[i] + start, session );
        }
        result += locs.length;
      }
      return result;
View Full Code Here

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

    else {
      namedParameters = CollectionHelper.mapOfSize( queryParameters.getNamedParameters().size() );
      Iterator itr = queryParameters.getNamedParameters().entrySet().iterator();
      while ( itr.hasNext() ) {
        final Map.Entry namedParameterEntry = ( Map.Entry ) itr.next();
        final TypedValue original = ( TypedValue ) namedParameterEntry.getValue();
        namedParameters.put(
            namedParameterEntry.getKey(),
            new TypedValue(
                original.getType(),
                original.getType().disassemble( original.getValue(), session, null ),
                session.getEntityMode()
            )
        );
      }
    }
View Full Code Here

    return ( ( Loadable ) getPropertyMapping( getEntityName( subcriteria ) ) ).getIdentifierType();
  }

  public TypedValue getTypedIdentifierValue(Criteria subcriteria, Object value) {
    final Loadable loadable = ( Loadable ) getPropertyMapping( getEntityName( subcriteria ) );
    return new TypedValue(
        loadable.getIdentifierType(),
            value,
            EntityMode.POJO
    );
  }
View Full Code Here

          value = nullableType.fromStringValue( stringValue );
        }
        else {
          throw new QueryException( "Unsupported discriminator type " + type );
        }
        return new TypedValue(
            type,
                value,
                EntityMode.POJO
        );
      }
    }
    // Otherwise, this is an ordinary value.
    return new TypedValue(
        getTypeUsingProjection( subcriteria, propertyName ),
            value,
            EntityMode.POJO
    );
  }
View Full Code Here

  public String toString(Map namedTypedValues) throws HibernateException {
    Map result = new HashMap();
    Iterator iter = namedTypedValues.entrySet().iterator();
    while ( iter.hasNext() ) {
      Map.Entry me = (Map.Entry) iter.next();
      TypedValue tv = (TypedValue) me.getValue();
      result.put( me.getKey(), tv.getType().toLoggableString( tv.getValue(), factory ) );
    }
    return result.toString();
  }
View Full Code Here

TOP

Related Classes of org.hibernate.engine.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.