Package org.eclipse.persistence.internal.jpa.metadata.accessors.mappings

Examples of org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor


     * again. If still no accessor is found and this descriptor represents an
     * inheritance subclass, then traverse up the chain to look for that
     * accessor. Null is returned otherwise.
     */
    public MappingAccessor getAccessorFor(String fieldOrPropertyName) {
        MappingAccessor accessor = m_accessors.get(fieldOrPropertyName);
       
        if (accessor == null) {
            // Perhaps we have a property name ...
            accessor = m_accessors.get(MetadataMethod.getAttributeNameFromMethodName(fieldOrPropertyName));
          
View Full Code Here


     * references. If the referencingAccessor is null, no check will be made.
     */
    public DatabaseMapping getMappingForAttributeName(String attributeName, MetadataAccessor referencingAccessor) {
        // Get accessor will traverse the parent descriptors of an inheritance
        // hierarchy.
        MappingAccessor accessor = getAccessorFor(attributeName);
       
        if (accessor != null) {
            // If the accessor is a relationship accessor than it may or may
            // not have been processed yet. Fast track its processing if it
            // needs to be. The process call will do nothing if it has already
            // been processed.
            if (accessor.isRelationship()) {
                RelationshipAccessor relationshipAccessor = (RelationshipAccessor) accessor;
               
                // Check that we don't have circular mappedBy values which
                // will cause an infinite loop.
                if (referencingAccessor != null && (relationshipAccessor.isOneToOne() || relationshipAccessor.isCollectionAccessor())) {
                    String mappedBy = null;
                   
                    if (relationshipAccessor.isOneToOne()) {
                        mappedBy = ((OneToOneAccessor) relationshipAccessor).getMappedBy();
                    } else {
                        mappedBy = ((CollectionAccessor) relationshipAccessor).getMappedBy();
                    }
                   
                    if (mappedBy != null && mappedBy.equals(referencingAccessor.getAttributeName())) {
                        throw ValidationException.circularMappedByReferences(referencingAccessor.getJavaClass(), referencingAccessor.getAttributeName(), getJavaClass(), attributeName);
                    }
                }
               
                relationshipAccessor.processRelationship();
            }
           
            // Return the mapping from the accessors descriptor since it may
            // be our descriptor or a parent descriptor from an inheritance
            // hierarchy.
            return accessor.getDescriptor().getClassDescriptor().getMappingForAttributeName(attributeName);
        }
       
        // We didn't find a mapping on our descriptor (or a parent descriptor),
        // check our aggregate descriptors now.
        for (MetadataDescriptor embeddableDescriptor : m_embeddableDescriptors) {
View Full Code Here

     * again. If still no accessor is found and this descriptor represents an
     * inheritance subclass, then traverse up the chain to look for that
     * accessor. Null is returned otherwise.
     */
    public MappingAccessor getAccessorFor(String fieldOrPropertyName) {
        MappingAccessor accessor = m_accessors.get(fieldOrPropertyName);
       
        if (accessor == null) {
            // Perhaps we have a property name ...
            accessor = m_accessors.get(MetadataMethod.getAttributeNameFromMethodName(fieldOrPropertyName));
          
View Full Code Here

     * references. If the referencingAccessor is null, no check will be made.
     */
    public DatabaseMapping getMappingForAttributeName(String attributeName, MetadataAccessor referencingAccessor) {
        // Get accessor will traverse the parent descriptors of an inheritance
        // hierarchy.
        MappingAccessor accessor = getAccessorFor(attributeName);
       
        if (accessor != null) {
            // If the accessor is a relationship accessor than it may or may
            // not have been processed yet. Fast track its processing if it
            // needs to be. The process call will do nothing if it has already
            // been processed.
            if (accessor.isRelationship()) {
                RelationshipAccessor relationshipAccessor = (RelationshipAccessor) accessor;
               
                // Check that we don't have circular mappedBy values which
                // will cause an infinite loop.
                if (referencingAccessor != null && (relationshipAccessor.isOneToOne() || relationshipAccessor.isCollectionAccessor())) {
                    String mappedBy = null;
                   
                    if (relationshipAccessor.isOneToOne()) {
                        mappedBy = ((OneToOneAccessor) relationshipAccessor).getMappedBy();
                    } else {
                        mappedBy = ((CollectionAccessor) relationshipAccessor).getMappedBy();
                    }
                   
                    if (mappedBy != null && mappedBy.equals(referencingAccessor.getAttributeName())) {
                        throw ValidationException.circularMappedByReferences(referencingAccessor.getJavaClass(), referencingAccessor.getAttributeName(), getJavaClass(), attributeName);
                    }
                }
               
                relationshipAccessor.processRelationship();
            }
           
            // Return the mapping from the accessors descriptor since it may
            // be our descriptor or a parent descriptor from an inheritance
            // hierarchy.
            return accessor.getDescriptor().getClassDescriptor().getMappingForAttributeName(attributeName);
        }
       
        // We didn't find a mapping on our descriptor (or a parent descriptor),
        // check our aggregate descriptors now.
        for (MetadataDescriptor embeddableDescriptor : m_embeddableDescriptors) {
View Full Code Here

     * again. If still no accessor is found and this descriptor represents an
     * inheritance subclass, then traverse up the chain to look for that
     * accessor. Null is returned otherwise.
     */
    public MappingAccessor getAccessorFor(String fieldOrPropertyName) {
        MappingAccessor accessor = m_accessors.get(fieldOrPropertyName);
       
        if (accessor == null) {
            // Perhaps we have a property name ...
            accessor = m_accessors.get(MetadataMethod.getAttributeNameFromMethodName(fieldOrPropertyName));
          
View Full Code Here

     * references. If the referencingAccessor is null, no check will be made.
     */
    public DatabaseMapping getMappingForAttributeName(String attributeName, MetadataAccessor referencingAccessor) {
        // Get accessor will traverse the parent descriptors of an inheritance
        // hierarchy.
        MappingAccessor accessor = getAccessorFor(attributeName);
       
        if (accessor != null) {
            // If the accessor is a relationship accessor than it may or may
            // not have been processed yet. Fast track its processing if it
            // needs to be. The process call will do nothing if it has already
            // been processed.
            if (accessor.isRelationship()) {
                RelationshipAccessor relationshipAccessor = (RelationshipAccessor) accessor;
               
                // Check that we don't have circular mappedBy values which
                // will cause an infinite loop.
                if (referencingAccessor != null && (relationshipAccessor.isOneToOne() || relationshipAccessor.isCollectionAccessor())) {
                    String mappedBy = null;
                   
                    if (relationshipAccessor.isOneToOne()) {
                        mappedBy = ((OneToOneAccessor) relationshipAccessor).getMappedBy();
                    } else {
                        mappedBy = ((CollectionAccessor) relationshipAccessor).getMappedBy();
                    }
                   
                    if (mappedBy != null && mappedBy.equals(referencingAccessor.getAttributeName())) {
                        throw ValidationException.circularMappedByReferences(referencingAccessor.getJavaClass(), referencingAccessor.getAttributeName(), getJavaClass(), attributeName);
                    }
                }
               
                relationshipAccessor.processRelationship();
            }
           
            // Return the mapping from the accessors descriptor since it may
            // be our descriptor or a parent descriptor from an inheritance
            // hierarchy.
            return accessor.getDescriptor().getClassDescriptor().getMappingForAttributeName(attributeName);
        }
       
        // We didn't find a mapping on our descriptor (or a parent descriptor),
        // check our aggregate descriptors now.
        for (MetadataDescriptor embeddableDescriptor : m_embeddableDescriptors) {
View Full Code Here

                    } else {
                        ((DirectCollectionMapping) mapping).addAscendingOrdering();
                    }
                } else {
                    // Validate the order by reference.
                    MappingAccessor referenceAccessor = referenceDescriptor.getMappingAccessor(propertyOrFieldName);
                    if (referenceAccessor == null) {
                        throw ValidationException.invalidOrderByValue(propertyOrFieldName, referenceDescriptor.getJavaClass(), getAccessibleObjectName(), javaClass);
                    }

                    String attributeName = referenceAccessor.getAttributeName();

                    if (referenceAccessor.isEmbedded()) {
                        for (String orderByAttributeName : referenceDescriptor.getOrderByAttributeNames()) {
                            mapping.addAggregateOrderBy(propertyOrFieldName, orderByAttributeName, ordering.equals(DESCENDING));
                        }
                    } else if (referenceAccessor.getClassAccessor().isEmbeddableAccessor()) {
                        // We have a specific order by from an embeddable, we need to rip off
                        // the last bit of a dot notation if specified and pass in the chained
                        // string names of the nested embeddables only.
                        String embeddableChain = "";
                        if (propertyOrFieldName.contains(".")) {
View Full Code Here

            return;
        }
       
        // Log a warning message if we are overriding a mapping accessor.
        if (m_mappingAccessors.containsKey(accessor.getAttributeName())) {
            MappingAccessor existingAccessor = m_mappingAccessors.get(accessor.getAttributeName());
            String existingAccessType = existingAccessor.usesPropertyAccess() ? JPA_ACCESS_PROPERTY : JPA_ACCESS_FIELD;
            String accessType = accessor.usesPropertyAccess() ? JPA_ACCESS_PROPERTY : JPA_ACCESS_FIELD;
            getLogger().logWarningMessage(getLogger().INVERSE_ACCESS_TYPE_MAPPING_OVERRIDE, accessor.getJavaClass().getName(), existingAccessor.getAnnotatedElementName(), existingAccessType, accessor.getAnnotatedElementName(), accessType);
        }
       
        m_mappingAccessors.put(accessor.getAttributeName(), accessor);
       
        // Store IdAccessors in a separate map for use by hasIdAccessor()
View Full Code Here

     * accessor is found and this descriptor represents an inheritance subclass,
     * then traverse up the chain to look for that accessor. Null is returned
     * otherwise.
     */
    protected MappingAccessor getMappingAccessor(String fieldOrPropertyName, boolean checkForMethodName) {
        MappingAccessor accessor = m_mappingAccessors.get(fieldOrPropertyName);
       
        if (accessor == null) {
            // Perhaps we have a method name. This is value add, and maybe we
            // really shouldn't do this but it covers the following case:
            // <order-by>age, getGender DESC</order-by>, where the user
            // specifies a method name.
            if (checkForMethodName) {
                accessor = m_mappingAccessors.get(Helper.getAttributeNameFromMethodName(fieldOrPropertyName));
            }
          
            // If still no accessor and we are an inheritance subclass, check
            // our parent descriptor. Unless we are within a table per class
            // strategy in which case, if the mapping doesn't exist within our
            // accessor list, we don't want to deal with it.
            if (accessor == null && isInheritanceSubclass() && ! usesTablePerClassInheritanceStrategy()) {
                accessor = getInheritanceParentDescriptor().getMappingAccessor(fieldOrPropertyName, checkForMethodName);
            }
        }
       
        if (accessor == null) {
            // Traverse any dot notation (nested embeddables) if specified.
            if (fieldOrPropertyName.contains(".")) {
                String attributeName = fieldOrPropertyName.substring(0, fieldOrPropertyName.indexOf("."));
                String subAttributeName = fieldOrPropertyName.substring(fieldOrPropertyName.indexOf(".") + 1);
           
                MappingAccessor embeddedAccessor = m_mappingAccessors.get(attributeName);
           
                if (embeddedAccessor != null) {
                    accessor = embeddedAccessor.getReferenceDescriptor().getMappingAccessor(subAttributeName, checkForMethodName);
                }
            }

            // If we are still null, maybe the user has not used a dot notation
            // that is, has not been fully specific. At this point this is value
View Full Code Here

            StringTokenizer commaTokenizer = new StringTokenizer(m_value, ",");
       
            while (commaTokenizer.hasMoreTokens()) {
                StringTokenizer spaceTokenizer = new StringTokenizer(commaTokenizer.nextToken());
                String propertyOrFieldName = spaceTokenizer.nextToken();
                MappingAccessor referenceAccessor = referenceDescriptor.getMappingAccessor(propertyOrFieldName);
           
                if (referenceAccessor == null) {
                    throw ValidationException.invalidOrderByValue(propertyOrFieldName, referenceDescriptor.getJavaClass(), getAccessibleObjectName(), javaClass);
                }

                String attributeName = referenceAccessor.getAttributeName();
                String ordering = (spaceTokenizer.hasMoreTokens()) ? spaceTokenizer.nextToken() : ASCENDING;

                if (referenceAccessor.isEmbedded()) {
                    for (String orderByAttributeName : referenceDescriptor.getOrderByAttributeNames()) {
                        mapping.addAggregateOrderBy(m_value, orderByAttributeName, ordering.equals(DESCENDING));
                    }
                } else if (referenceAccessor.getClassAccessor().isEmbeddableAccessor()) {
                    // We have a specific order by from an embeddable, we need to rip off
                    // the last bit of a dot notation if specified and pass in the chained
                    // string names of the nested embeddables only.
                    String embeddableChain = m_value;
                    if (embeddableChain.contains(".")) {
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor

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.