private static PropertyData getUniqueIdPropertyFromBaseClass( PropertyData inferredData, PropertyData baseInferredData, AccessType propertyAccessor, MetadataBuildingContext context) { List<PropertyData> baseClassElements = new ArrayList<>(); XClass baseReturnedClassOrElement = baseInferredData.getClassOrElement(); PropertyContainer propContainer = new PropertyContainer( baseReturnedClassOrElement, inferredData.getPropertyClass(), propertyAccessor ); addElementsOfClass( baseClassElements, propContainer, context ); //Id properties are on top and there is only one return baseClassElements.get( 0 ); }
public Collection<XProperty> getProperties() { assertTypesAreResolvable(); return Collections.unmodifiableCollection( persistentAttributeMap.values() ); }
private void assertTypesAreResolvable() { for ( XProperty xProperty : persistentAttributeMap.values() ) { if ( !xProperty.isTypeResolved() && !discoverTypeWithoutReflection( xProperty ) ) { String msg = "Property " + StringHelper.qualify( xClass.getName(), xProperty.getName() ) + " has an unbound type and no explicit target entity. Resolve this Generic usage issue" + " or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type"; throw new AnnotationException( msg ); } } } //
PropertyContainer(XClass clazz, XClass entityAtStake) { this.xClass = clazz; this.entityAtStake = entityAtStake; fieldAccessMap = initProperties( AccessType.FIELD ); propertyAccessMap = initProperties( AccessType.PROPERTY ); explicitClassDefinedAccessType = determineClassDefinedAccessStrategy(); checkForJpaAccess(); }
final XClass declaringClass = propertyContainer.getDeclaringClass(); final XClass entity = propertyContainer.getEntityAtStake(); int idPropertyCounter = 0; PropertyData propertyAnnotatedElement = new PropertyInferredData( declaringClass, property, propertyContainer.getClassLevelAccessType().getType(), context.getBootstrapContext().getReflectionManager() ); propertyContainer.getClassLevelAccessType().getType(),
/** * @param elements List of {@code ProperyData} instances * @param defaultAccessType The default value access strategy which has to be used in case no explicit local access * strategy is used * @param propertyContainer Metadata about a class and its properties * @param mappings Mapping meta data * * @return the number of id properties found while iterating the elements of {@code annotatedClass} using * the determined access strategy, {@code false} otherwise. */ static int addElementsOfClass( List<PropertyData> elements, AccessType defaultAccessType, PropertyContainer propertyContainer, ExtendedMappings mappings ) { int idPropertyCounter = 0; AccessType accessType = defaultAccessType; if ( propertyContainer.hasExplicitAccessStrategy() ) { accessType = propertyContainer.getExplicitAccessStrategy(); } propertyContainer.assertTypesAreResolvable( accessType ); Collection<XProperty> properties = propertyContainer.getProperties( accessType ); for ( XProperty p : properties ) { final int currentIdPropertyCounter = addProperty( propertyContainer, p, elements, accessType.getType(), mappings ); idPropertyCounter += currentIdPropertyCounter; } return idPropertyCounter; }
String propertyAccessor, ExtendedMappings mappings ) { final XClass declaringClass = propertyContainer.getDeclaringClass(); final XClass entity = propertyContainer.getEntityAtStake(); int idPropertyCounter = 0; PropertyData propertyAnnotatedElement = new PropertyInferredData(
/** * @param elements List of {@code ProperyData} instances * @param defaultAccessType The default value access strategy which has to be used in case no explicit local access * strategy is used * @param propertyContainer Metadata about a class and its properties * @param mappings Mapping meta data * * @return the number of id properties found while iterating the elements of {@code annotatedClass} using * the determined access strategy, {@code false} otherwise. */ static int addElementsOfClass( List<PropertyData> elements, AccessType defaultAccessType, PropertyContainer propertyContainer, Mappings mappings) { int idPropertyCounter = 0; AccessType accessType = defaultAccessType; if ( propertyContainer.hasExplicitAccessStrategy() ) { accessType = propertyContainer.getExplicitAccessStrategy(); } Collection<XProperty> properties = propertyContainer.getProperties( accessType ); for ( XProperty p : properties ) { final int currentIdPropertyCounter = addProperty( propertyContainer, p, elements, accessType.getType(), mappings ); idPropertyCounter += currentIdPropertyCounter; } return idPropertyCounter; }
PropertyContainer(XClass clazz, XClass entityAtStake) { this.xClass = clazz; this.entityAtStake = entityAtStake; explicitClassDefinedAccessType = determineClassDefinedAccessStrategy(); // first add all properties to field and property map fieldAccessMap = initProperties( AccessType.FIELD ); propertyAccessMap = initProperties( AccessType.PROPERTY ); considerExplicitFieldAndPropertyAccess(); }
private void preFilter(List<XProperty> fields, List<XProperty> getters) { Iterator<XProperty> propertyIterator = fields.iterator(); while ( propertyIterator.hasNext() ) { final XProperty property = propertyIterator.next(); if ( mustBeSkipped( property ) ) { propertyIterator.remove(); } } propertyIterator = getters.iterator(); while ( propertyIterator.hasNext() ) { final XProperty property = propertyIterator.next(); if ( mustBeSkipped( property ) ) { propertyIterator.remove(); } } }
/** * @param elements List of {@code ProperyData} instances * @param propertyContainer Metadata about a class and its properties * * @return the number of id properties found while iterating the elements of {@code annotatedClass} using * the determined access strategy, {@code false} otherwise. */ static int addElementsOfClass( List<PropertyData> elements, PropertyContainer propertyContainer, MetadataBuildingContext context) { int idPropertyCounter = 0; Collection<XProperty> properties = propertyContainer.getProperties(); for ( XProperty p : properties ) { final int currentIdPropertyCounter = addProperty( propertyContainer, p, elements, context ); idPropertyCounter += currentIdPropertyCounter; } return idPropertyCounter; }
String propertyAccessor, Mappings mappings) { final XClass declaringClass = propertyContainer.getDeclaringClass(); final XClass entity = propertyContainer.getEntityAtStake(); int idPropertyCounter = 0; PropertyData propertyAnnotatedElement = new PropertyInferredData(
final XClass declaringClass = propertyContainer.getDeclaringClass(); final XClass entity = propertyContainer.getEntityAtStake(); int idPropertyCounter = 0; PropertyData propertyAnnotatedElement = new PropertyInferredData( declaringClass, property, propertyContainer.getClassLevelAccessType().getType(), context.getBootstrapContext().getReflectionManager() ); propertyContainer.getClassLevelAccessType().getType(),
/** * @param elements List of {@code ProperyData} instances * @param defaultAccessType The default value access strategy which has to be used in case no explicit local access * strategy is used * @param propertyContainer Metadata about a class and its properties * @param mappings Mapping meta data * * @return the number of id properties found while iterating the elements of {@code annotatedClass} using * the determined access strategy, {@code false} otherwise. */ static int addElementsOfClass( List<PropertyData> elements, AccessType defaultAccessType, PropertyContainer propertyContainer, Mappings mappings) { int idPropertyCounter = 0; AccessType accessType = defaultAccessType; if ( propertyContainer.hasExplicitAccessStrategy() ) { accessType = propertyContainer.getExplicitAccessStrategy(); } Collection<XProperty> properties = propertyContainer.getProperties( accessType ); for ( XProperty p : properties ) { final int currentIdPropertyCounter = addProperty( propertyContainer, p, elements, accessType.getType(), mappings ); idPropertyCounter += currentIdPropertyCounter; } return idPropertyCounter; }
PropertyContainer(XClass clazz, XClass entityAtStake) { this.xClass = clazz; this.entityAtStake = entityAtStake; explicitClassDefinedAccessType = determineClassDefinedAccessStrategy(); // first add all properties to field and property map fieldAccessMap = initProperties( AccessType.FIELD ); propertyAccessMap = initProperties( AccessType.PROPERTY ); considerExplicitFieldAndPropertyAccess(); }
private TreeMap<String, XProperty> initProperties(AccessType access) { //order so that property are used in the same order when binding native query TreeMap<String, XProperty> propertiesMap = new TreeMap<String, XProperty>(); List<XProperty> properties = xClass.getDeclaredProperties( access.getType() ); for ( XProperty property : properties ) { if ( mustBeSkipped( property ) ) { continue; } propertiesMap.put( property.getName(), property ); } return propertiesMap; }
/** * @param elements List of {@code ProperyData} instances * @param propertyContainer Metadata about a class and its properties * * @return the number of id properties found while iterating the elements of {@code annotatedClass} using * the determined access strategy, {@code false} otherwise. */ static int addElementsOfClass( List<PropertyData> elements, PropertyContainer propertyContainer, MetadataBuildingContext context) { int idPropertyCounter = 0; Collection<XProperty> properties = propertyContainer.getProperties(); for ( XProperty p : properties ) { final int currentIdPropertyCounter = addProperty( propertyContainer, p, elements, context ); idPropertyCounter += currentIdPropertyCounter; } return idPropertyCounter; }
public ElementsToProcess getElementsToProcess() { if ( elementsToProcess == null ) { InheritanceState inheritanceState = inheritanceStatePerClass.get( clazz ); assert !inheritanceState.isEmbeddableSuperclass(); getMappedSuperclassesTillNextEntityOrdered(); accessType = determineDefaultAccessType(); ArrayList<PropertyData> elements = new ArrayList<PropertyData>(); int idPropertyCount = 0; for ( XClass classToProcessForMappedSuperclass : classesToProcessForMappedSuperclass ) { PropertyContainer propertyContainer = new PropertyContainer( classToProcessForMappedSuperclass, clazz, accessType ); int currentIdPropertyCount = AnnotationBinder.addElementsOfClass( elements, propertyContainer, buildingContext ); idPropertyCount += currentIdPropertyCount; } if ( idPropertyCount == 0 && !inheritanceState.hasParents() ) { throw new AnnotationException( "No identifier specified for entity: " + clazz.getName() ); } elements.trimToSize(); elementsToProcess = new ElementsToProcess( elements, idPropertyCount ); } return elementsToProcess; }
String propertyAccessor, Mappings mappings) { final XClass declaringClass = propertyContainer.getDeclaringClass(); final XClass entity = propertyContainer.getEntityAtStake(); int idPropertyCounter = 0; PropertyData propertyAnnotatedElement = new PropertyInferredData(
public void assertTypesAreResolvable(AccessType access) { TreeMap<String, XProperty> xprops; if ( AccessType.PROPERTY.equals( access ) || AccessType.DEFAULT.equals( access ) ) { xprops = propertyAccessMap; } else { xprops = fieldAccessMap; } for ( XProperty property : xprops.values() ) { if ( !property.isTypeResolved() && !discoverTypeWithoutReflection( property ) ) { String msg = "Property " + StringHelper.qualify( xClass.getName(), property.getName() ) + " has an unbound type and no explicit target entity. Resolve this Generic usage issue" + " or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type"; throw new AnnotationException( msg ); } } }