Package org.hibernate.engine

Examples of org.hibernate.engine.TypedValue


  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


    java.util.Set currentIds = new HashSet();
    for ( Iterator it=currentElements.iterator(); it.hasNext(); ) {
      Object current = it.next();
      if ( current!=null && ForeignKeys.isNotTransient(entityName, current, null, session) ) {
        Serializable currentId = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, current, session);
        currentIds.add( new TypedValue( idType, currentId, session.getEntityMode() ) );
      }
    }

    // iterate over the *old* list
    for ( Iterator it=oldElements.iterator(); it.hasNext(); ) {
      Object old = it.next();
      Serializable oldId = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, old, session);
      if ( !currentIds.contains( new TypedValue( idType, oldId, session.getEntityMode() ) ) ) {
        res.add(old);
      }
    }

    return res;
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

      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

  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, session.getEntityMode() ) );
       return this;
    }
  }
View Full Code Here

  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, session.getEntityMode() ) );
    return this;
  }
View Full Code Here

  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

   
    Type[] ppTypes = params.getPositionalParameterTypes();
    Object[] ppValues = params.getPositionalParameterValues();
    TypedValue[] tv = new TypedValue[ppTypes.length];
    for ( int i=0; i<ppTypes.length; i++ ) {
      tv[i] = new TypedValue( ppTypes[i], ppValues[i], EntityMode.POJO );
    }
    return tv;
  }
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.