Package org.hibernate.mapping

Examples of org.hibernate.mapping.Property


          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

      jpaMappingType.getBuilder().applyIdClassAttributes( attributes );
    }
  }

  private <X> void applyVersionAttribute(PersistentClass persistentClass, EntityTypeImpl<X> jpaEntityType) {
    final Property declaredVersion = persistentClass.getDeclaredVersion();
    if (declaredVersion != null) {
      jpaEntityType.getBuilder().applyVersionAttribute(
          attributeFactory.buildVersionAttribute( jpaEntityType, declaredVersion )
      );
    }
View Full Code Here

      );
    }
  }

  private <X> void applyVersionAttribute(MappedSuperclass mappingType, MappedSuperclassTypeImpl<X> jpaMappingType) {
    final Property declaredVersion = mappingType.getDeclaredVersion();
    if ( declaredVersion != null ) {
      jpaMappingType.getBuilder().applyVersionAttribute(
          attributeFactory.buildVersionAttribute( jpaMappingType, declaredVersion )
      );
    }
View Full Code Here

            "property-ref to unmapped class: " +
            upr.referencedClass
          );
      }

      Property prop = clazz.getReferencedProperty( upr.propertyName );
      if ( upr.unique ) {
        ( (SimpleValue) prop.getValue() ).setAlternateUniqueKey( true );
      }
    }

    //TODO: Somehow add the newly created foreign keys to the internal collection
View Full Code Here

      public Type getReferencedPropertyType(String persistentClass, String propertyName) throws MappingException {
        final PersistentClass pc = (PersistentClass) classes.get( persistentClass );
        if ( pc == null ) {
          throw new MappingException( "persistent class not known: " + persistentClass );
        }
        Property prop = pc.getReferencedProperty( propertyName );
        if ( prop == null ) {
          throw new MappingException(
              "property not known: " +
              persistentClass + '.' + propertyName
            );
        }
        return prop.getType();
      }
    };
  }
View Full Code Here

    this.lifecycleImplementor = Lifecycle.class.isAssignableFrom( mappedClass );
    this.validatableImplementor = Validatable.class.isAssignableFrom( mappedClass );

    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

    }

    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.error(
            "Getters of lazy classes cannot be final: " + persistentClass.getEntityName() +
            "." + property.getName()
          );
      }
      method = property.getSetter(clazz).getMethod();
            if ( method != null && Modifier.isFinal( method.getModifiers() ) ) {
        log.error(
            "Setters of lazy classes cannot be final: " + persistentClass.getEntityName() +
            "." + property.getName()
          );
      }
    }

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

    naturalOrderPropertyTableNumbers = new int[hydrateSpan];
    propertyTableNumbers = new int[hydrateSpan];
    Iterator iter = persistentClass.getPropertyClosureIterator();
    int i=0;
    while( iter.hasNext() ) {
      Property prop = (Property) iter.next();
      String tabname = prop.getValue().getTable().getQualifiedName(
        factory.getDialect(),
        factory.getSettings().getDefaultCatalogName(),
        factory.getSettings().getDefaultSchemaName()
      );
      propertyTableNumbers[i] = getTableId(tabname, tableNames);
      naturalOrderPropertyTableNumbers[i] = getTableId(tabname, naturalOrderTableNames);
      i++;
    }

    // subclass closure properties

    //TODO: code duplication with SingleTableEntityPersister

    ArrayList columnTableNumbers = new ArrayList();
    ArrayList formulaTableNumbers = new ArrayList();
    ArrayList propTableNumbers = new ArrayList();

    iter = persistentClass.getSubclassPropertyClosureIterator();
    while ( iter.hasNext() ) {
      Property prop = (Property) iter.next();
      Table tab = prop.getValue().getTable();
      String tabname = tab.getQualifiedName(
          factory.getDialect(),
          factory.getSettings().getDefaultCatalogName(),
          factory.getSettings().getDefaultSchemaName()
      );
      Integer tabnum = new Integer( getTableId(tabname, subclassTableNameClosure) );
      propTableNumbers.add(tabnum);

      Iterator citer = prop.getColumnIterator();
      while ( citer.hasNext() ) {
        Selectable thing = (Selectable) citer.next();
        if ( thing.isFormula() ) {
          formulaTableNumbers.add(tabnum);
        }
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.