Package org.hibernate.mapping

Examples of org.hibernate.mapping.Value


      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

      // If this is not a persistent property, with the same access type as currently checked,
      // it's not audited as well.
      // If the property was already defined by the subclass, is ignored by superclasses
      if ((persistentProperties.contains(property.getName()) && (!auditedPropertiesHolder
          .contains(property.getName())))) {
        Value propertyValue = persistentPropertiesSource.getProperty(property.getName()).getValue();
        if (propertyValue instanceof Component) {
          this.addFromComponentProperty(property, accessType, (Component)propertyValue, allClassAudited);
        } else {
          this.addFromNotComponentProperty(property, accessType, allClassAudited);
        }
      } else if (propertiesGroupMapping.containsKey(property.getName())) {
        // Retrieve embedded component name based on class field.
        final String embeddedName = propertiesGroupMapping.get(property.getName());
        if (!auditedPropertiesHolder.contains(embeddedName)) {
          // Manage properties mapped within <properties> tag.
          Value propertyValue = persistentPropertiesSource.getProperty(embeddedName).getValue();
          this.addFromPropertiesGroup(embeddedName, property, accessType, (Component)propertyValue, allClassAudited);
        }
      }
    }
  }
View Full Code Here

    // TODO (steve->emmanuel) not so sure this is true any longer...
    // FIXME the logical level for *To* is different from the Hibernate physical model.
    //    ie a @ManyToOne @AssocTable is a many-to-many for hibernate
    //    and a @OneToMany @AssocTable is a many-to-many for hibernate
    // FIXME so basically Attribute.PersistentAttributeType is crap at the moment
    final Value value = attributeContext.getPropertyMapping().getValue();
    final org.hibernate.type.Type type = value.getType();
    if ( type.isAnyType() ) {
      throw new UnsupportedOperationException( "any not supported yet" );
    }
    else if ( type.isAssociationType() ) {
      // collection or entity
      if ( type.isEntityType() ) {
        // entity
        return new SingularAttributeMetadataImpl<X,Y>(
            attributeContext.getPropertyMapping(),
            attributeContext.getOwnerType(),
            member,
            determineSingularAssociationAttributeType( member )
        );
      }
      else {
        // collection
        if ( value instanceof Collection ) {
          final Collection collValue = (Collection) value;
          final Value elementValue = collValue.getElement();
          final org.hibernate.type.Type elementType = elementValue.getType();

          // First, determine the type of the elements and use that to help determine the
          //     collection type)
          final Attribute.PersistentAttributeType elementPersistentAttributeType;
          final Attribute.PersistentAttributeType persistentAttributeType;
          if ( elementType.isAnyType() ) {
            throw new UnsupportedOperationException( "collection of any not supported yet" );
          }
          final boolean isManyToMany = isManyToMany( member );
          if ( elementValue instanceof Component ) {
            elementPersistentAttributeType = Attribute.PersistentAttributeType.EMBEDDED;
            persistentAttributeType = Attribute.PersistentAttributeType.ELEMENT_COLLECTION;
          }
          else if ( elementType.isAssociationType() ) {
            elementPersistentAttributeType = isManyToMany
                ? Attribute.PersistentAttributeType.MANY_TO_MANY
                : Attribute.PersistentAttributeType.ONE_TO_MANY;
            persistentAttributeType = elementPersistentAttributeType;
          }
          else {
            elementPersistentAttributeType = Attribute.PersistentAttributeType.BASIC;
            persistentAttributeType = Attribute.PersistentAttributeType.ELEMENT_COLLECTION;
          }

          final Attribute.PersistentAttributeType keyPersistentAttributeType;

          // Finally, we determine the type of the map key (if needed)
          if ( value instanceof Map ) {
            final Value keyValue = ( ( Map ) value ).getIndex();
            final org.hibernate.type.Type keyType = keyValue.getType();

            if ( keyType.isAnyType() ) {
              throw new UnsupportedOperationException( "collection of any not supported yet" );
            }
            if ( keyValue instanceof Component ) {
View Full Code Here

        referencedEntityName = MappingTools.getReferencedEntityName(propertyValue.getElement());
    }

    void addCollection() {
        Type type = propertyValue.getType();
        Value value = propertyValue.getElement();

        boolean oneToManyAttachedType = type instanceof BagType || type instanceof SetType || type instanceof MapType || type instanceof ListType;
        boolean inverseOneToMany = (value instanceof OneToMany) && (propertyValue.isInverse());
        boolean owningManyToOneWithJoinTableBidirectional = (value instanceof ManyToOne) && (propertyAuditingData.getAuditMappedBy() != null);
        boolean fakeOneToManyBidirectional = (value instanceof OneToMany) && (propertyAuditingData.getAuditMappedBy() != null);
View Full Code Here

    mappings.addNamedEntityGraphDefintion( new NamedEntityGraphDefinition( annotation, name, persistentClass.getEntityName() ) );
  }
 
  public void bindDiscriminatorValue() {
    if ( StringHelper.isEmpty( discriminatorValue ) ) {
      Value discriminator = persistentClass.getDiscriminator();
      if ( discriminator == null ) {
        persistentClass.setDiscriminatorValue( name );
      }
      else if ( "character".equals( discriminator.getType().getName() ) ) {
        throw new AnnotationException(
            "Using default @DiscriminatorValue for a discriminator of type CHAR is not safe"
        );
      }
      else if ( "integer".equals( discriminator.getType().getName() ) ) {
        persistentClass.setDiscriminatorValue( String.valueOf( name.hashCode() ) );
      }
      else {
        persistentClass.setDiscriminatorValue( name ); //Spec compliant
      }
View Full Code Here

      final Property property = associatedClass.getRecursiveProperty( columns[0].getMappedBy() );
      Iterator mappedByColumns;
      if ( property.getValue() instanceof Collection ) {
        Collection collection = ( (Collection) property.getValue() );
        Value element = collection.getElement();
        if ( element == null ) {
          throw new AnnotationException(
              "Illegal use of mappedBy on both sides of the relationship: "
                  + associatedClass.getEntityName() + "." + mappedByProperty
          );
        }
        mappedByColumns = element.getColumnIterator();
      }
      else {
        mappedByColumns = property.getValue().getColumnIterator();
      }
      while ( mappedByColumns.hasNext() ) {
View Full Code Here

        throw new AnnotationException(
            "Map key property not found: " + collType + "." + mapKeyPropertyName
        );
      }
      org.hibernate.mapping.Map map = (org.hibernate.mapping.Map) this.collection;
      Value indexValue = createFormulatedValue(
          mapProperty.getValue(), map, targetPropertyName, associatedClass, mappings
      );
      map.setIndex( indexValue );
    }
    else {
View Full Code Here

      MemberResolver memberResolver) {
        LOG.trace("Starting attribute metadata determination [" + attributeContext.getPropertyMapping().getName() + "]");
    final Member member = memberResolver.resolveMember( attributeContext );
        LOG.trace("    Determined member [" + member + "]");

    final Value value = attributeContext.getPropertyMapping().getValue();
    final org.hibernate.type.Type type = value.getType();
        LOG.trace("    Determined type [name=" + type.getName() + ", class=" + type.getClass().getName() + "]");

    if ( type.isAnyType() ) {
      throw new UnsupportedOperationException( "any not supported yet" );
    }
    else if ( type.isAssociationType() ) {
      // collection or entity
      if ( type.isEntityType() ) {
        // entity
        return new SingularAttributeMetadataImpl<X,Y>(
            attributeContext.getPropertyMapping(),
            attributeContext.getOwnerType(),
            member,
            determineSingularAssociationAttributeType( member )
        );
      }
            // collection
            if (value instanceof Collection) {
                final Collection collValue = (Collection)value;
                final Value elementValue = collValue.getElement();
                final org.hibernate.type.Type elementType = elementValue.getType();

                // First, determine the type of the elements and use that to help determine the
                // collection type)
                final Attribute.PersistentAttributeType elementPersistentAttributeType;
                final Attribute.PersistentAttributeType persistentAttributeType;
                if (elementType.isAnyType()) {
                    throw new UnsupportedOperationException("collection of any not supported yet");
                }
                final boolean isManyToMany = isManyToMany(member);
                if (elementValue instanceof Component) {
                    elementPersistentAttributeType = Attribute.PersistentAttributeType.EMBEDDED;
                    persistentAttributeType = Attribute.PersistentAttributeType.ELEMENT_COLLECTION;
                } else if (elementType.isAssociationType()) {
                    elementPersistentAttributeType = isManyToMany ? Attribute.PersistentAttributeType.MANY_TO_MANY : Attribute.PersistentAttributeType.ONE_TO_MANY;
                    persistentAttributeType = elementPersistentAttributeType;
                } else {
                    elementPersistentAttributeType = Attribute.PersistentAttributeType.BASIC;
                    persistentAttributeType = Attribute.PersistentAttributeType.ELEMENT_COLLECTION;
                }

                final Attribute.PersistentAttributeType keyPersistentAttributeType;

                // Finally, we determine the type of the map key (if needed)
                if (value instanceof Map) {
                    final Value keyValue = ((Map)value).getIndex();
                    final org.hibernate.type.Type keyType = keyValue.getType();

                    if (keyType.isAnyType()) throw new UnsupportedOperationException("collection of any not supported yet");
                    if (keyValue instanceof Component) keyPersistentAttributeType = Attribute.PersistentAttributeType.EMBEDDED;
                    else if (keyType.isAssociationType()) keyPersistentAttributeType = Attribute.PersistentAttributeType.MANY_TO_ONE;
                    else keyPersistentAttributeType = Attribute.PersistentAttributeType.BASIC;
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

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.