Package org.hibernate.mapping

Examples of org.hibernate.mapping.Property


  public static IdentifierProperty buildIdentifierAttribute(
      PersistentClass mappedEntity,
      IdentifierGenerator generator) {
    String mappedUnsavedValue = mappedEntity.getIdentifier().getNullValue();
    Type type = mappedEntity.getIdentifier().getType();
    Property property = mappedEntity.getIdentifierProperty();
   
    IdentifierValue unsavedValue = UnsavedValueFactory.getUnsavedIdentifierValue(
        mappedUnsavedValue,
        getGetter( property ),
        type,
        getConstructor(mappedEntity)
      );

    if ( property == null ) {
      // this is a virtual id property...
      return new IdentifierProperty(
              type,
          mappedEntity.hasEmbeddedIdentifier(),
          mappedEntity.hasIdentifierMapper(),
          unsavedValue,
          generator
        );
    }
    else {
      return new IdentifierProperty(
          property.getName(),
          property.getNodeName(),
          type,
          mappedEntity.hasEmbeddedIdentifier(),
          unsavedValue,
          generator
        );
View Full Code Here


    propertySpan = component.getPropertySpan();
    properties = new StandardProperty[propertySpan];
    Iterator itr = component.getPropertyIterator();
    int i = 0;
    while ( itr.hasNext() ) {
      Property property = ( Property ) itr.next();
      properties[i] = PropertyFactory.buildStandardProperty( property, false );
      propertyIndexes.put( property.getName(), i );
      i++;
    }

    entityMode = component.hasPojoRepresentation() ? EntityMode.POJO : EntityMode.MAP;
View Full Code Here

            (ComponentType) typeContext.getValue().getType()
        );
        context.registerEmbeddedableType( embeddableType );
        final Iterator<Property> subProperties = component.getPropertyIterator();
        while ( subProperties.hasNext() ) {
          final Property property = subProperties.next();
          final AttributeImplementor<Y, Object> attribute = buildAttribute( embeddableType, property );
          if ( attribute != null ) {
            embeddableType.getBuilder().addAttribute( attribute );
          }
        }
View Full Code Here

    this.lifecycleImplementor = Lifecycle.class.isAssignableFrom( mappedClass );
    this.isInstrumented = entityMetamodel.isInstrumented();

    Iterator iter = mappedEntity.getPropertyClosureIterator();
    while ( iter.hasNext() ) {
      Property property = (Property) iter.next();
      if ( property.isLazy() ) {
        lazyPropertyNames.add( property.getName() );
      }
    }

    String[] getterNames = new String[propertySpan];
    String[] setterNames = new String[propertySpan];
View Full Code Here

    proxyInterfaces.add( HibernateProxy.class );

    Iterator properties = persistentClass.getPropertyIterator();
    Class clazz = persistentClass.getMappedClass();
    while ( properties.hasNext() ) {
      Property property = (Property) properties.next();
      Method method = property.getGetter(clazz).getMethod();
      if ( method != null && Modifier.isFinal( method.getModifiers() ) ) {
                LOG.gettersOfLazyClassesCannotBeFinal(persistentClass.getEntityName(), property.getName());
      }
      method = property.getSetter(clazz).getMethod();
            if ( method != null && Modifier.isFinal( method.getModifiers() ) ) {
                LOG.settersOfLazyClassesCannotBeFinal(persistentClass.getEntityName(), property.getName());
      }
    }

    Method idGetterMethod = idGetter==null ? null : idGetter.getMethod();
    Method idSetterMethod = idSetter==null ? null : idSetter.getMethod();
View Full Code Here

    propertyTableNumbers = new int[ getPropertySpan() ];
    Iterator iter = persistentClass.getPropertyClosureIterator();
    int i=0;
    while( iter.hasNext() ) {
      Property prop = (Property) iter.next();
      propertyTableNumbers[i++] = persistentClass.getJoinNumber(prop);

    }

    //TODO: code duplication with JoinedSubclassEntityPersister
   
    ArrayList columnJoinNumbers = new ArrayList();
    ArrayList formulaJoinedNumbers = new ArrayList();
    ArrayList propertyJoinNumbers = new ArrayList();
   
    iter = persistentClass.getSubclassPropertyClosureIterator();
    while ( iter.hasNext() ) {
      Property prop = (Property) iter.next();
      Integer join = new Integer( persistentClass.getJoinNumber(prop) );
      propertyJoinNumbers.add(join);

      //propertyTableNumbersByName.put( prop.getName(), join );
      propertyTableNumbersByNameAndSubclass.put(
          prop.getPersistentClass().getEntityName() + '.' + prop.getName(),
          join
      );

      Iterator citer = prop.getColumnIterator();
      while ( citer.hasNext() ) {
        Selectable thing = (Selectable) citer.next();
        if ( thing.isFormula() ) {
          formulaJoinedNumbers.add(join);
        }
View Full Code Here

    iter = persistentClass.getPropertyClosureIterator();
    i = 0;
    boolean foundFormula = false;
    while ( iter.hasNext() ) {
      Property prop = ( Property ) iter.next();
      thisClassProperties.add( prop );

      int span = prop.getColumnSpan();
      propertyColumnSpans[i] = span;
      propertySubclassNames[i] = prop.getPersistentClass().getEntityName();
      String[] colNames = new String[span];
      String[] colAliases = new String[span];
      String[] colReaderTemplates = new String[span];
      String[] colWriters = new String[span];
      String[] formulaTemplates = new String[span];
      Iterator colIter = prop.getColumnIterator();
      int k = 0;
      while ( colIter.hasNext() ) {
        Selectable thing = ( Selectable ) colIter.next();
        colAliases[k] = thing.getAlias( factory.getDialect() , prop.getValue().getTable() );
        if ( thing.isFormula() ) {
          foundFormula = true;
          formulaTemplates[k] = thing.getTemplate( factory.getDialect(), factory.getSqlFunctionRegistry() );
        }
        else {
          Column col = (Column)thing;
          colNames[k] = col.getQuotedName( factory.getDialect() );
          colReaderTemplates[k] = col.getTemplate( factory.getDialect(), factory.getSqlFunctionRegistry() );
          colWriters[k] = col.getWriteExpr();
        }
        k++;
      }
      propertyColumnNames[i] = colNames;
      propertyColumnFormulaTemplates[i] = formulaTemplates;
      propertyColumnReaderTemplates[i] = colReaderTemplates;
      propertyColumnWriters[i] = colWriters;
      propertyColumnAliases[i] = colAliases;

      if ( lazyAvailable && prop.isLazy() ) {
        lazyProperties.add( prop.getName() );
        lazyNames.add( prop.getName() );
        lazyNumbers.add( new Integer( i ) );
        lazyTypes.add( prop.getValue().getType() );
        lazyColAliases.add( colAliases );
      }

      propertyColumnUpdateable[i] = prop.getValue().getColumnUpdateability();
      propertyColumnInsertable[i] = prop.getValue().getColumnInsertability();

      propertySelectable[i] = prop.isSelectable();

      propertyUniqueness[i] = prop.getValue().isAlternateUniqueKey();

      i++;

    }
    hasFormulaProperties = foundFormula;
    lazyPropertyColumnAliases = ArrayHelper.to2DStringArray( lazyColAliases );
    lazyPropertyNames = ArrayHelper.toStringArray( lazyNames );
    lazyPropertyNumbers = ArrayHelper.toIntArray( lazyNumbers );
    lazyPropertyTypes = ArrayHelper.toTypeArray( lazyTypes );

    // SUBCLASS PROPERTY CLOSURE

    ArrayList columns = new ArrayList();
    ArrayList columnsLazy = new ArrayList();
    ArrayList columnReaderTemplates = new ArrayList();
    ArrayList aliases = new ArrayList();
    ArrayList formulas = new ArrayList();
    ArrayList formulaAliases = new ArrayList();
    ArrayList formulaTemplates = new ArrayList();
    ArrayList formulasLazy = new ArrayList();
    ArrayList types = new ArrayList();
    ArrayList names = new ArrayList();
    ArrayList classes = new ArrayList();
    ArrayList templates = new ArrayList();
    ArrayList propColumns = new ArrayList();
    ArrayList propColumnReaders = new ArrayList();
    ArrayList propColumnReaderTemplates = new ArrayList();
    ArrayList joinedFetchesList = new ArrayList();
    ArrayList cascades = new ArrayList();
    ArrayList definedBySubclass = new ArrayList();
    ArrayList propColumnNumbers = new ArrayList();
    ArrayList propFormulaNumbers = new ArrayList();
    ArrayList columnSelectables = new ArrayList();
    ArrayList propNullables = new ArrayList();

    iter = persistentClass.getSubclassPropertyClosureIterator();
    while ( iter.hasNext() ) {
      Property prop = ( Property ) iter.next();
      names.add( prop.getName() );
      classes.add( prop.getPersistentClass().getEntityName() );
      boolean isDefinedBySubclass = !thisClassProperties.contains( prop );
      definedBySubclass.add( Boolean.valueOf( isDefinedBySubclass ) );
      propNullables.add( Boolean.valueOf( prop.isOptional() || isDefinedBySubclass ) ); //TODO: is this completely correct?
      types.add( prop.getType() );

      Iterator colIter = prop.getColumnIterator();
      String[] cols = new String[prop.getColumnSpan()];
      String[] readers = new String[prop.getColumnSpan()];
      String[] readerTemplates = new String[prop.getColumnSpan()];
      String[] forms = new String[prop.getColumnSpan()];
      int[] colnos = new int[prop.getColumnSpan()];
      int[] formnos = new int[prop.getColumnSpan()];
      int l = 0;
      Boolean lazy = Boolean.valueOf( prop.isLazy() && lazyAvailable );
      while ( colIter.hasNext() ) {
        Selectable thing = ( Selectable ) colIter.next();
        if ( thing.isFormula() ) {
          String template = thing.getTemplate( factory.getDialect(), factory.getSqlFunctionRegistry() );
          formnos[l] = formulaTemplates.size();
          colnos[l] = -1;
          formulaTemplates.add( template );
          forms[l] = template;
          formulas.add( thing.getText( factory.getDialect() ) );
          formulaAliases.add( thing.getAlias( factory.getDialect() ) );
          formulasLazy.add( lazy );
        }
        else {
          Column col = (Column)thing;
          String colName = col.getQuotedName( factory.getDialect() );
          colnos[l] = columns.size(); //before add :-)
          formnos[l] = -1;
          columns.add( colName );
          cols[l] = colName;
          aliases.add( thing.getAlias( factory.getDialect(), prop.getValue().getTable() ) );
          columnsLazy.add( lazy );
          columnSelectables.add( Boolean.valueOf( prop.isSelectable() ) );
         
          readers[l] = col.getReadExpr( factory.getDialect() );
          String readerTemplate = col.getTemplate( factory.getDialect(), factory.getSqlFunctionRegistry() );
          readerTemplates[l] = readerTemplate;
          columnReaderTemplates.add( readerTemplate );
        }
        l++;
      }
      propColumns.add( cols );
      propColumnReaders.add( readers );
      propColumnReaderTemplates.add( readerTemplates );
      templates.add( forms );
      propColumnNumbers.add( colnos );
      propFormulaNumbers.add( formnos );

      joinedFetchesList.add( prop.getValue().getFetchMode() );
      cascades.add( prop.getCascadeStyle() );
    }
    subclassColumnClosure = ArrayHelper.toStringArray( columns );
    subclassColumnAliasClosure = ArrayHelper.toStringArray( aliases );
    subclassColumnLazyClosure = ArrayHelper.toBooleanArray( columnsLazy );
    subclassColumnSelectableClosure = ArrayHelper.toBooleanArray( columnSelectables );
View Full Code Here

          final EntityTypeImpl<?> jpa2Mapping = entityTypesByPersistentClass.get( safeMapping );
          applyIdMetadata( safeMapping, jpa2Mapping );
          applyVersionAttribute( safeMapping, jpa2Mapping );
          Iterator<Property> properties = safeMapping.getDeclaredPropertyIterator();
          while ( properties.hasNext() ) {
            final Property property = properties.next();
            if ( property.getValue() == safeMapping.getIdentifierMapper() ) {
              // property represents special handling for id-class mappings but we have already
              // accounted for the embedded property mappings in #applyIdMetadata &&
              // #buildIdClassAttributes
              continue;
            }
            if ( safeMapping.isVersioned() && property == safeMapping.getVersion() ) {
              // skip the version property, it was already handled previously.
              continue;
            }
            final Attribute attribute = attributeFactory.buildAttribute( jpa2Mapping, property );
            if ( attribute != null ) {
              jpa2Mapping.getBuilder().addAttribute( attribute );
            }
          }
          jpa2Mapping.lock();
          populateStaticMetamodel( jpa2Mapping );
        }
        finally {
                    LOG.trace("Completed entity [" + safeMapping.getEntityName() + "]");
        }
      }
      else if ( MappedSuperclass.class.isAssignableFrom( mapping.getClass() ) ) {
        @SuppressWarnings( "unchecked" )
        final MappedSuperclass safeMapping = (MappedSuperclass) mapping;
                LOG.trace("Starting mapped superclass [" + safeMapping.getMappedClass().getName() + "]");
        try {
          final MappedSuperclassTypeImpl<?> jpa2Mapping = mappedSuperclassByMappedSuperclassMapping.get(
              safeMapping
          );
          applyIdMetadata( safeMapping, jpa2Mapping );
          applyVersionAttribute( safeMapping, jpa2Mapping );
          Iterator<Property> properties = safeMapping.getDeclaredPropertyIterator();
          while ( properties.hasNext() ) {
            final Property property = properties.next();
            if ( safeMapping.isVersioned() && property == safeMapping.getVersion() ) {
              // skip the version property, it was already handled previously.
              continue;
            }
            final Attribute attribute = attributeFactory.buildAttribute( jpa2Mapping, property );
View Full Code Here

  }


  private <X> void applyIdMetadata(PersistentClass persistentClass, EntityTypeImpl<X> jpaEntityType) {
    if ( persistentClass.hasIdentifierProperty() ) {
      final Property declaredIdentifierProperty = persistentClass.getDeclaredIdentifierProperty();
      if (declaredIdentifierProperty != null) {
        jpaEntityType.getBuilder().applyIdAttribute(
            attributeFactory.buildIdAttribute( jpaEntityType, declaredIdentifierProperty )
        );
      }
View Full Code Here

    }
  }

  private <X> void applyIdMetadata(MappedSuperclass mappingType, MappedSuperclassTypeImpl<X> jpaMappingType) {
    if ( mappingType.hasIdentifierProperty() ) {
      final Property declaredIdentifierProperty = mappingType.getDeclaredIdentifierProperty();
      if (declaredIdentifierProperty != null) {
        jpaMappingType.getBuilder().applyIdAttribute(
            attributeFactory.buildIdAttribute( jpaMappingType, declaredIdentifierProperty )
        );
      }
View Full Code Here

TOP

Related Classes of org.hibernate.mapping.Property

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.