Package org.hibernate.mapping

Examples of org.hibernate.mapping.Value


            this.processClass(pojoClazz);
           
            Iterator properties = clazz.getPropertyIterator();
            while (properties.hasNext() ) {
                Property property = (Property) properties.next();
                Value value = property.getValue();               
                List props = (List) propsByValue.get(value);
                if (props == null) {
                    props = new ArrayList();
                    propsByValue.put(value, props);
                }
View Full Code Here


        return qualifiedSchemaName + '.' + table.getName();
    }
   
    public String getPropertyType(Property p){
      Value v = p.getValue();
      Type t;
      String propertyString = "N/D";     
      try{
        t = v.getType();       
        propertyString = t.getReturnedClass().getName();
       
      }
      catch(Exception ex){
        //TODO we should try to get the value from value here
View Full Code Here

    public List getProperties(Table table, Column column) {

        List result = new ArrayList();
        Iterator values = getValues(table, column).iterator();
        while (values.hasNext() ) {
            Value value = (Value) values.next();
            List props = (List) propsByValue.get(value);
            if (props != null) {
                result.addAll(props);
            }
        }
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

 
  public String getName() {
    return "cache";
  }
  public void visitProperty(Configuration configuration, PersistentClass clazz, Property property, IssueCollector collector) {
    Value value = property.getValue();
   
    if(value instanceof Collection) {
      Collection col = (Collection) value;
      if(col.getCacheConcurrencyStrategy()!=null) { // caching is enabled
        if (!col.getElement().isSimpleValue()) {
View Full Code Here

    }
    return toolTag;
  }

  public String getCollectionElementTag(Property property){
    Value value = property.getValue();
    if (isOneToMany(value)) return "one-to-many";
    if (isManyToMany(value)) return "many-to-many";
    if (isManyToAny(value)) return "many-to-any";
    if (((Collection)value).getElement() instanceof Component){
      return "composite";
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

      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() ) {
      // ANY mappings are currently not supported in the JPA metamodel; see HHH-6589
            if ( context.isIgnoreUnsupported() ) {
                return null;
            }
      else {
                throw new UnsupportedOperationException( "ANY not supported" );
            }
    }
    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

    // 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;
        discriminatorColumnReaders = null;
        discriminatorColumnReaderTemplate = null;
        discriminatorAlias = "clazz_";
      }
      else {
        Column column = (Column) selectable;
        discriminatorColumnName = column.getQuotedName( factory.getDialect() );
        discriminatorColumnReaders = column.getReadExpr( factory.getDialect() );
        discriminatorColumnReaderTemplate = column.getTemplate( factory.getDialect(), factory.getSqlFunctionRegistry() );
        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

         */
        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.