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


    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

   *
   * @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

    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

    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

  }

  public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
  throws HibernateException {
    return new TypedValue[] {
      new TypedValue( Hibernate.INTEGER, new Integer(size), EntityMode.POJO )
    };
  }
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

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.