Package org.hibernate.mapping

Examples of org.hibernate.mapping.Property


    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[] templates = 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;
          templates[k] = thing.getTemplate( factory.getDialect(), factory.getSqlFunctionRegistry() );
        }
        else {
          colNames[k] = thing.getTemplate( factory.getDialect(), factory.getSqlFunctionRegistry() );
        }
        k++;
      }
      propertyColumnNames[i] = colNames;
      propertyColumnFormulaTemplates[i] = templates;
      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 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 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[] 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 {
          String colName = thing.getTemplate( factory.getDialect(), factory.getSqlFunctionRegistry() );
          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() ) );
        }
        l++;
      }
      propColumns.add( cols );
      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


  }

  private void internalInitSubclassPropertyAliasesMap(String path, Iterator propertyIterator) {
    while ( propertyIterator.hasNext() ) {

      Property prop = ( Property ) propertyIterator.next();
      String propname = path == null ? prop.getName() : path + "." + prop.getName();
      if ( prop.isComposite() ) {
        Component component = ( Component ) prop.getValue();
        Iterator compProps = component.getPropertyIterator();
        internalInitSubclassPropertyAliasesMap( propname, compProps );
      }
      else {
        String[] aliases = new String[prop.getColumnSpan()];
        String[] cols = new String[prop.getColumnSpan()];
        Iterator colIter = prop.getColumnIterator();
        int l = 0;
        while ( colIter.hasNext() ) {
          Selectable thing = ( Selectable ) colIter.next();
          aliases[l] = thing.getAlias( getFactory().getDialect(), prop.getValue().getTable() );
          cols[l] = thing.getText( getFactory().getDialect() ); // TODO: skip formulas?
          l++;
        }

        subclassPropertyAliases.put( propname, aliases );
View Full Code Here

            exporter.startEmbeddedIdentifier( (Component)clazz.getKey() );
            exporter.endEmbeddedIdentifier( (Component)clazz.getKey() );
                }
                Iterator unjoinedPropertyIterator = clazz.getUnjoinedPropertyIterator();
                while(unjoinedPropertyIterator.hasNext() ) {
                    Property prop = (Property)unjoinedPropertyIterator.next();
                    exporter.startProperty(prop);
                    exporter.endProperty(prop);
                }
            }
            exporter.endPersistentClass(clazz);
View Full Code Here

    collectComponents( components, iter );   
  }
 
  private static void collectComponents(Map components, Iterator iter) {
    while(iter.hasNext()) {
      Property property = (Property) iter.next();
      if (!"embedded".equals(property.getPropertyAccessorName()) && // HBX-267, embedded property for <properties> should not be generated as component.
        property.getValue() instanceof Component) {
        Component comp = (Component) property.getValue();
        addComponent( components, comp );     
      }
      else if (property.getValue() instanceof Collection) {
        // compisite-element in collection
        Collection collection = (Collection) property.getValue();       
        if ( collection.getElement() instanceof Component) {
          Component comp = (Component) collection.getElement();       
          addComponent(components, comp);       
        }
      }
View Full Code Here

    // Need to skip <properties> element which are defined via "embedded" components
    // Best if we could return an intelligent iterator, but for now we just iterate explicitly.
    Iterator pit = pc.getPropertyIterator();
    while(pit.hasNext())
    {
      Property element = (Property) pit.next();
      if ( element.getValue() instanceof Component
          && element.getPropertyAccessorName().equals( "embedded" )) {
        Component component = (Component) element.getValue();
        // need to "explode" property to get proper sequence in java code.
        Iterator embeddedProperty = component.getPropertyIterator();
        while(embeddedProperty.hasNext()) {
          properties.add(embeddedProperty.next());
        }
View Full Code Here

    Iterator properties = pc.getPropertyClosureIterator();
    //TODO we should check the table too
    boolean isOtherSide = false;
    mappedBy = "unresolved";
    while ( ! isOtherSide && properties.hasNext() ) {
      Property collectionProperty = (Property) properties.next();
      Value collectionValue = collectionProperty.getValue();
      if ( collectionValue != null && collectionValue instanceof Collection ) {
        Collection realCollectionValue = (Collection) collectionValue;
        if ( ! realCollectionValue.isOneToMany() ) {
          if ( joinColumns.size() == realCollectionValue.getElement().getColumnSpan() ) {
            isOtherSide = true;
            Iterator it = realCollectionValue.getElement().getColumnIterator();
            while ( it.hasNext() ) {
              Object column = it.next();
              if (! joinColumns.contains( column ) ) {
                isOtherSide = false;
                break;
              }
            }
            if (isOtherSide) {
              mappedBy = collectionProperty.getName();
            }
          }
        }
      }
    }
View Full Code Here

    Iterator properties = pc.getPropertyClosureIterator();
    //TODO we should check the table too
    boolean isOtherSide = false;
    mappedBy = "unresolved";
    while ( ! isOtherSide && properties.hasNext() ) {
      Property manyProperty = (Property) properties.next();
      Value manyValue = manyProperty.getValue();
      if ( manyValue != null && manyValue instanceof ManyToOne ) {
        if ( joinColumns.size() == manyValue.getColumnSpan() ) {
          isOtherSide = true;
          Iterator it = manyValue.getColumnIterator();
          while ( it.hasNext() ) {
            Object column = it.next();
            if (! joinColumns.contains( column ) ) {
              isOtherSide = false;
              break;
            }
          }
          if (isOtherSide) {
            mappedBy = manyProperty.getName();
          }
        }

      }
    }
View Full Code Here

    boolean isOtherSide = false;
    mappedBy = "unresolved";


    while ( ! isOtherSide && properties.hasNext() ) {
      Property oneProperty = (Property) properties.next();
      Value manyValue = oneProperty.getValue();
      if ( manyValue != null && ( manyValue instanceof OneToOne || manyValue instanceof ManyToOne ) ) {
        if ( joinColumns.size() == manyValue.getColumnSpan() ) {
          isOtherSide = true;
          Iterator it = manyValue.getColumnIterator();
          while ( it.hasNext() ) {
            Object column = it.next();
            if (! joinColumns.contains( column ) ) {
              isOtherSide = false;
              break;
            }
          }
          if (isOtherSide) {
            mappedBy = oneProperty.getName();
          }
        }

      }
    }
View Full Code Here

  protected List getPropertiesForFullConstructor(PersistentClass pc) {
    List result = new ArrayList();

    for ( Iterator myFields = getAllPropertiesIterator(pc); myFields.hasNext() ; ) {
      Property field = (Property) myFields.next();
      // TODO: if(!field.isGenerated() ) ) {
      if(field.equals(pc.getIdentifierProperty()) && !isAssignedIdentifier(pc, field)) {
        continue; // dont add non assigned identifiers
      } else if(field.equals(pc.getVersion())) {
        continue; // version prop
      } else if(field.isBackRef()) {
        continue;
      } else if(isFormula(field)) {
        continue;
      } else {
        result.add( field );
View Full Code Here

  protected List getPropertiesForMinimalConstructor(PersistentClass pc) {
    List result = new ArrayList();

    for ( Iterator myFields = getAllPropertiesIterator(pc); myFields.hasNext() ; ) {
      Property property = (Property) myFields.next();
      if(property.equals(pc.getIdentifierProperty())) {
        if(isAssignedIdentifier(pc, property)) {
          result.add(property);
        } else {
          continue;
        }
      } else if (property.equals(pc.getVersion())) {
        continue; // the version property should not be in the result.
      } else if( isRequiredInConstructor(property) ) {
        result.add(property);
      }
    }
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.