Package org.hibernate.type

Examples of org.hibernate.type.CompositeType


    }

    // aliases for composite-id's
    if ( getIdentifierType().isComponentType() ) {
      // Fetch embedded identifiers propertynames from the "virtual" identifier component
      CompositeType componentId = ( CompositeType ) getIdentifierType();
      String[] idPropertyNames = componentId.getPropertyNames();
      String[] idAliases = getIdentifierAliases();
      String[] idColumnNames = getIdentifierColumnNames();

      for ( int i = 0; i < idPropertyNames.length; i++ ) {
        if ( entityMetamodel.hasNonIdentifierPropertyNamedId() ) {
View Full Code Here


      CollectionType collectionType = (CollectionType) propertyType;
      Type collectionElementType = collectionType.getElementType( session.getFactory() );
      if ( collectionElementType.isComponentType() ) {
        //check for all components values in the collection

        CompositeType componentType = (CompositeType) collectionElementType;
        Iterator iter = CascadingAction.getLoadedElementsIterator( session, collectionType, value );
        while ( iter.hasNext() ) {
          Object compValue = iter.next();
          if (compValue != null) {
            return checkComponentNullability(compValue, componentType);
View Full Code Here

   * {@inheritDoc}
   */
  public void setIdentifier(Object entity, Serializable id, SessionImplementor session) {
    if ( entityMetamodel.getIdentifierProperty().isEmbedded() ) {
      if ( entity != id ) {
        CompositeType copier = (CompositeType) entityMetamodel.getIdentifierProperty().getType();
        copier.setPropertyValues( entity, copier.getPropertyValues( id, getEntityMode() ), getEntityMode() );
      }
    }
    else if ( idSetter != null ) {
      idSetter.set( entity, id, getFactory() );
    }
View Full Code Here

  public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
  throws HibernateException {
    ArrayList list = new ArrayList();
    Type type = criteriaQuery.getTypeUsingProjection(criteria, propertyName);
    if ( type.isComponentType() ) {
      CompositeType actype = (CompositeType) type;
      Type[] types = actype.getSubtypes();
      for ( int j=0; j<values.length; j++ ) {
        for ( int i=0; i<types.length; i++ ) {
          Object subval = values[j]==null ?
            null :
            actype.getPropertyValues( values[j], EntityMode.POJO )[i];
          list.add( new TypedValue( types[i], subval, EntityMode.POJO ) );
        }
      }
    }
    else {
View Full Code Here

          nullifier.isNullifiable( null, value ) ) {
        nonNullableTransientEntities.add( propertyName, value );
      }
    }
    else if ( type.isComponentType() ) {
      CompositeType actype = (CompositeType) type;
      boolean[] subValueNullability = actype.getPropertyNullability();
      if ( subValueNullability != null ) {
        String[] subPropertyNames = actype.getPropertyNames();
        Object[] subvalues = actype.getPropertyValues(value, session);
        Type[] subtypes = actype.getSubtypes();
        for ( int j = 0; j < subvalues.length; j++ ) {
          collectNonNullableTransientEntities(
              nullifier,
              j,
              subvalues[j],
View Full Code Here

      }
      else if ( type.isAnyType() ) {
        return isNullifiable(null, value) ? null : value;
      }
      else if ( type.isComponentType() ) {
        CompositeType actype = (CompositeType) type;
        Object[] subvalues = actype.getPropertyValues(value, session);
        Type[] subtypes = actype.getSubtypes();
        boolean substitute = false;
        for ( int i = 0; i < subvalues.length; i++ ) {
          Object replacement = nullifyTransientReferences( subvalues[i], subtypes[i] );
          if ( replacement != subvalues[i] ) {
            substitute = true;
            subvalues[i] = replacement;
          }
        }
        if ( substitute ) {
          // todo : need to account for entity mode on the CompositeType interface :(
          actype.setPropertyValues( value, subvalues, EntityMode.POJO );
        }
        return value;
      }
      else {
        return value;
View Full Code Here

    // if the entity has a composite identifier, see if we need to handle
    // its sub-properties separately
    final Type idType = persister.getIdentifierType();
    if ( idType.isComponentType() ) {
      final CompositeType cidType = (CompositeType) idType;
      if ( cidType.isEmbedded() ) {
        // we have an embedded composite identifier.  Most likely we need to process the composite
        // properties separately, although there is an edge case where the identifier is really
        // a simple identifier (single value) wrapped in a JPA @IdClass or even in the case of a
        // a simple identifier (single value) wrapped in a Hibernate composite type.
        //
View Full Code Here

        for ( Type type : types ) {
            if ( type.isCollectionType() ) {
                factory.getCache().evictCollection( ( (CollectionType) type ).getRole(), id );
            }
            else if ( type.isComponentType() ) {
                CompositeType actype = (CompositeType) type;
                evictCachedCollections( actype.getSubtypes(), id, factory );
            }
        }
  }
View Full Code Here

    collectionPropertyColumnAliases.put( aliasName, columnAliases );
    collectionPropertyColumnNames.put( aliasName, columnNames );

    if ( type.isComponentType() ) {
      CompositeType ct = (CompositeType) type;
      String[] propertyNames = ct.getPropertyNames();
      for ( int i = 0; i < propertyNames.length; i++ ) {
        String name = propertyNames[i];
        collectionPropertyColumnAliases.put( aliasName + "." + name, columnAliases[i] );
        collectionPropertyColumnNames.put( aliasName + "." + name, columnNames[i] );
      }
View Full Code Here

    }

    if (path!=null) addPropertyPath(path, type, columns, columnReaders, columnReaderTemplates, formulaTemplates);

    if ( type.isComponentType() ) {
      CompositeType actype = (CompositeType) type;
      initComponentPropertyPaths( path, actype, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory );
      if ( actype.isEmbedded() ) {
        initComponentPropertyPaths(
            path==null ? null : StringHelper.qualifier(path),
            actype,
            columns,
            columnReaders,
View Full Code Here

TOP

Related Classes of org.hibernate.type.CompositeType

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.