Package org.hibernate.type

Examples of org.hibernate.type.Type


    int nonfilteredParamCount = queryParameters.getPositionalParameterTypes() == null
        ? 0
        : queryParameters.getPositionalParameterTypes().length;
    int filterParamCount = filteredParamCount - nonfilteredParamCount;
    for ( int i = 0; i < filterParamCount; i++ ) {
      Type type = queryParameters.getFilteredPositionalParameterTypes()[i];
      Object value = queryParameters.getFilteredPositionalParameterValues()[i];
      type.nullSafeSet( st, value, position, session );
      position += type.getColumnSpan( getFactory() );
    }

    return position;
  }
View Full Code Here


  public boolean isWrapper(Object collection) {
    return array==collection;
  }

  public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
    Type elementType = persister.getElementType();
    Serializable snapshot = getSnapshot();
    int xlen = Array.getLength(snapshot);
    if ( xlen!= Array.getLength(array) ) return false;
    for ( int i=0; i<xlen; i++) {
      if ( elementType.isDirty( Array.get(snapshot, i), Array.get(array, i), getSession() ) ) return false;
    }
    return true;
  }
View Full Code Here

      final CascadeStyle style,
      final Object anything,
      final CollectionType type) {
    CollectionPersister persister = eventSource.getFactory()
        .getCollectionPersister( type.getRole() );
    Type elemType = persister.getElementType();

    final int oldCascadeTo = cascadeTo;
    if ( cascadeTo==AFTER_INSERT_BEFORE_DELETE) {
      cascadeTo = AFTER_INSERT_BEFORE_DELETE_VIA_COLLECTION;
    }

    //cascade to current collection elements
    if ( elemType.isEntityType() || elemType.isAnyType() || elemType.isComponentType() ) {
      cascadeCollectionElements(
        child,
        type,
        style,
        elemType,
View Full Code Here

  public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {
    this.bag = ( List ) persister.getCollectionType().instantiate( anticipatedSize );
  }

  public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
    Type elementType = persister.getElementType();
    EntityMode entityMode = getSession().getEntityMode();
    List sn = (List) getSnapshot();
    if ( sn.size()!=bag.size() ) return false;
    Iterator iter = bag.iterator();
    while ( iter.hasNext() ) {
View Full Code Here

  // Anyway, here we implement <set> semantics for a
  // <one-to-many> <bag>!

  public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
    //if ( !persister.isOneToMany() ) throw new AssertionFailure("Not implemented for Bags");
    Type elementType = persister.getElementType();
    EntityMode entityMode = getSession().getEntityMode();
    ArrayList deletes = new ArrayList();
    List sn = (List) getSnapshot();
    Iterator olditer = sn.iterator();
    int i=0;
    while ( olditer.hasNext() ) {
      Object old = olditer.next();
      Iterator newiter = bag.iterator();
      boolean found = false;
      if ( bag.size()>i && elementType.isSame( old, bag.get(i++), entityMode ) ) {
      //a shortcut if its location didn't change!
        found = true;
      }
      else {
        //search for it
        //note that this code is incorrect for other than one-to-many
        while ( newiter.hasNext() ) {
          if ( elementType.isSame( old, newiter.next(), entityMode ) ) {
            found = true;
            break;
          }
        }
      }
View Full Code Here

    if ( isSingleRowLoader() && id != null ) {
      resultId = id;
    }
    else {
     
      Type idType = persister.getIdentifierType();
      resultId = (Serializable) idType.nullSafeGet(
          rs,
          getEntityAliases()[i].getSuffixedKeyAliases(),
          session,
          null //problematic for <key-many-to-one>!
        );
     
      final boolean idIsResultId = id != null &&
          resultId != null &&
          idType.isEqual( id, resultId, session.getEntityMode(), factory );
     
      if ( idIsResultId ) resultId = id; //use the id passed in
    }

    return resultId == null ?
View Full Code Here

    final AssociationType[] ownerAssociationTypes = getOwnerAssociationTypes();
    if ( ownerAssociationTypes != null && ownerAssociationTypes[i] != null ) {
      String ukName = ownerAssociationTypes[i].getRHSUniqueKeyPropertyName();
      if (ukName!=null) {
        final int index = ( (UniqueKeyLoadable) persister ).getPropertyIndex(ukName);
        final Type type = persister.getPropertyTypes()[index];
 
        // polymorphism not really handled completely correctly,
        // perhaps...well, actually its ok, assuming that the
        // entity name used in the lookup is the same as the
        // the one used here, which it will be
 
        EntityUniqueKey euk = new EntityUniqueKey(
            rootPersister.getEntityName(), //polymorphism comment above
            ukName,
            type.semiResolve( values[index], session, object ),
            type,
            session.getEntityMode(), session.getFactory()
          );
        session.getPersistenceContext().addEntity( euk, object );
      }
View Full Code Here

    Map sn = (Map) snapshot;
    return getOrphans( sn.values(), map.values(), entityName, getSession() );
  }

  public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
    Type elementType = persister.getElementType();
    Map xmap = (Map) getSnapshot();
    if ( xmap.size()!=this.map.size() ) return false;
    Iterator iter = map.entrySet().iterator();
    while ( iter.hasNext() ) {
      Map.Entry entry = (Map.Entry) iter.next();
      if ( elementType.isDirty( entry.getValue(), xmap.get( entry.getKey() ), getSession() ) ) return false;
    }
    return true;
  }
View Full Code Here

        }
      }
      else { // dotcount>=2

        // Do the corresponding RHS
        Type propertyType = getPropertyType();

        if ( propertyType == null ) {
          throw new QueryException( "unresolved property: " + path );
        }

        if ( propertyType.isComponentType() ) {
          dereferenceComponent( token );
        }
        else if ( propertyType.isEntityType() ) {
          if ( !isCollectionValued() ) dereferenceEntity( token, ( EntityType ) propertyType, q );
        }
        else if ( propertyType.isCollectionType() ) {
          dereferenceCollection( token, ( ( CollectionType ) propertyType ).getRole(), q );

        }
        else {
          if ( token != null ) throw new QueryException( "dereferenced: " + path );
View Full Code Here

    }
  }

  protected Type getPropertyType() throws QueryException {
    String propertyPath = getPropertyPath();
    Type propertyType = getPropertyMapping().toType( propertyPath );
    if ( propertyType == null ) {
      throw new QueryException( "could not resolve property type: " + propertyPath );
    }
    return propertyType;
  }
View Full Code Here

TOP

Related Classes of org.hibernate.type.Type

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.