Package org.hibernate.mapping

Examples of org.hibernate.mapping.Value


         */
        if (pc == null)
          throw new MappingException("dotted notation in <return-join> or <load_collection> not yet supported");
        int dotIndex = name.lastIndexOf( '.' );
        String reducedName = name.substring( 0, dotIndex );
        Value value = pc.getRecursiveProperty( reducedName ).getValue();
        Iterator parentPropIter;
        if ( value instanceof Component ) {
          Component comp = (Component) value;
          parentPropIter = comp.getPropertyIterator();
        }
View Full Code Here


    super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, factory, mapping, resolveDiscriminator( persistentClass, factory ) );
  }

  private static EntityDiscriminator resolveDiscriminator(final PersistentClass persistentClass, final SessionFactoryImplementor factory) {
    if ( persistentClass.isPolymorphic() ) {
      Value discrimValue = persistentClass.getDiscriminator();
      Selectable selectable = (Selectable) discrimValue.getColumnIterator().next();
      if ( discrimValue.hasFormula() ) {
        throw new UnsupportedOperationException( "OGM doesn't support discriminator formulas" );
      }
      else {
        return new ColumnBasedDiscriminator( persistentClass, factory, (Column) selectable );
      }
View Full Code Here

        public void secondPass(Map persistentClasses, Map inheritedMetas) throws MappingException {
            JDBCBinder.bindCollectionSecondPass(collection, persistentClasses, mappings, inheritedMetas);
        }

        public void doSecondPass(Map persistentClasses) throws MappingException {
          Value element = collection.getElement();
          DependantValue dep = null;
          String oldFkName = null;
          if(element instanceof DependantValue) {
        dep = (DependantValue)element;
            oldFkName = dep.getForeignKeyName();
View Full Code Here

    return NONPRIMITIVETYPES.contains( typeName );
  }

  private String getRawTypeName(Property p, boolean useGenerics, boolean preferRawTypeNames, ImportContext importContext) {
    Value value = p.getValue();
    try {     
     
      if ( value instanceof Array ) { // array has a string rep.inside.
        Array a = (Array) value;       
         
        if ( a.isPrimitiveArray() ) {
          return toName( value.getType().getReturnedClass() );
        }
        else if (a.getElementClassName()!=null){
          return a.getElementClassName() + "[]";
        } else {
          return getJavaTypeName(a.getElement(), preferRawTypeNames) + "[]";
        }
      }

      if ( value instanceof Component ) { // same for component.       
        Component component = ( (Component) value );
        if(component.isDynamic()) return "java.util.Map";
        return component.getComponentClassName();
      }
     
      if ( useGenerics ) {
        if ( value instanceof Collection ) {
          String decl = getGenericCollectionDeclaration( (Collection) value, preferRawTypeNames, importContext );
          return getJavaTypeName(value, preferRawTypeNames) + decl;
        }
      }

      return getJavaTypeName( value, preferRawTypeNames );     
    }
    catch (Exception e) {
      //e.printStackTrace();
      String msg = "Could not resolve type without exception for " + p + " Value: " + value;
      if ( value != null && value.isSimpleValue() ) {
        String typename = ( (SimpleValue) value ).getTypeName();
        log.warn( msg + ". Falling back to typename: " + typename );
        return typename;
      }
      else {
View Full Code Here

      }
    }
  }

  public String getGenericCollectionDeclaration(Collection collection, boolean preferRawTypeNames, ImportContext importContext) {
    Value element = collection.getElement();
    String elementType = importContext.importType(getJavaTypeName(element, preferRawTypeNames));
    String genericDecl = elementType;
    if(collection.isIndexed()) {
      IndexedCollection idxCol = (IndexedCollection) collection;
      if(!idxCol.isList()) {
        Value idxElement = idxCol.getIndex();
        String indexType = importContext.importType(getJavaTypeName(idxElement, preferRawTypeNames));
        genericDecl = indexType + "," + elementType;
      }
    }
    String decl = "<" + genericDecl + ">";
View Full Code Here

         */
        if (pc == null)
          throw new MappingException("dotted notation in <return-join> or <load_collection> not yet supported");
        int dotIndex = name.lastIndexOf( '.' );
        String reducedName = name.substring( 0, dotIndex );
        Value value = pc.getRecursiveProperty( reducedName ).getValue();
        Iterator parentPropIter;
        if ( value instanceof Component ) {
          Component comp = (Component) value;
          parentPropIter = comp.getPropertyIterator();
        }
View Full Code Here

    // DISCRIMINATOR

    final Object discriminatorValue;
    if ( persistentClass.isPolymorphic() ) {
      Value discrimValue = persistentClass.getDiscriminator();
      if (discrimValue==null) {
        throw new MappingException("discriminator mapping required for single table polymorphic persistence");
      }
      forceDiscriminator = persistentClass.isForceDiscriminator();
      Selectable selectable = (Selectable) discrimValue.getColumnIterator().next();
      if ( discrimValue.hasFormula() ) {
        Formula formula = (Formula) selectable;
        discriminatorFormula = formula.getFormula();
        discriminatorFormulaTemplate = formula.getTemplate( factory.getDialect(), factory.getSqlFunctionRegistry() );
        discriminatorColumnName = null;
        discriminatorAlias = "clazz_";
      }
      else {
        Column column = (Column) selectable;
        discriminatorColumnName = column.getQuotedName( factory.getDialect() );
        discriminatorAlias = column.getAlias( factory.getDialect(), persistentClass.getRootTable() );
        discriminatorFormula = null;
        discriminatorFormulaTemplate = null;
      }
      discriminatorType = persistentClass.getDiscriminator().getType();
      if ( persistentClass.isDiscriminatorValueNull() ) {
        discriminatorValue = NULL_DISCRIMINATOR;
        discriminatorSQLValue = InFragment.NULL;
        discriminatorInsertable = false;
      }
      else if ( persistentClass.isDiscriminatorValueNotNull() ) {
        discriminatorValue = NOT_NULL_DISCRIMINATOR;
        discriminatorSQLValue = InFragment.NOT_NULL;
        discriminatorInsertable = false;
      }
      else {
        discriminatorInsertable = persistentClass.isDiscriminatorInsertable() && !discrimValue.hasFormula();
        try {
          DiscriminatorType dtype = (DiscriminatorType) discriminatorType;
          discriminatorValue = dtype.stringToObject( persistentClass.getDiscriminatorValue() );
          discriminatorSQLValue = dtype.objectToSQLString( discriminatorValue, factory.getDialect() );
        }
View Full Code Here

    while ( iter.hasNext() ) {
      Element subnode = (Element) iter.next();
      String name = subnode.getName();
      String propertyName = subnode.attributeValue( "name" );

      Value value = null;
      if ( "many-to-one".equals( name ) ) {
        value = new ManyToOne( table );
        bindManyToOne( subnode, (ManyToOne) value, propertyName, true, mappings );
      }
      else if ( "any".equals( name ) ) {
View Full Code Here

      String propertyName = getPropertyName( subnode );
      String subpath = propertyName == null ? null : StringHelper
        .qualify( path, propertyName );

      CollectionType collectType = CollectionType.collectionTypeFromString( name );
      Value value = null;
      if ( collectType != null ) {
        Collection collection = collectType.create(
            subnode,
            subpath,
            component.getOwner(),
View Full Code Here

      Element subnode = (Element) iter.next();
      String name = subnode.getName();
      String propertyName = subnode.attributeValue( "name" );

      CollectionType collectType = CollectionType.collectionTypeFromString( name );
      Value value = null;
      if ( collectType != null ) {
        Collection collection = collectType.create(
            subnode,
            StringHelper.qualify( entityName, propertyName ),
            persistentClass,
View Full Code Here

TOP

Related Classes of org.hibernate.mapping.Value

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.