private int getNumberOfParametersCoveredBy(Type[] subtypes) { int numberOfParameters = 0; for ( Type type : subtypes ) { if ( type.isComponentType() ) { numberOfParameters = numberOfParameters + getNumberOfParametersCoveredBy( ((ComponentType) type).getSubtypes() ); } else { numberOfParameters++; } } return numberOfParameters; }
for ( int i = 0; i < virtualIdComponent.getSubtypes().length; i++ ) { if ( virtualIdComponent.getSubtypes()[i].isEntityType() && !mappedIdClassComponentType.getSubtypes()[i].isEntityType() ) { wereAllEquivalent = false; break;
/** * Extract a component property value. * * @param type The component property types. * @param component The component instance itself. * @param propertyPath The property path for the property to be extracted. * * @return The property value extracted. */ protected Object getComponentValue(ComponentType type, Object component, String propertyPath) { final int loc = propertyPath.indexOf( '.' ); final String basePropertyName = loc > 0 ? propertyPath.substring( 0, loc ) : propertyPath; final int index = findSubPropertyIndex( type, basePropertyName ); final Object baseValue = type.getPropertyValue( component, index ); if ( loc > 0 ) { if ( baseValue == null ) { return null; } return getComponentValue( (ComponentType) type.getSubtypes()[index], baseValue, propertyPath.substring( loc + 1 ) ); } else { return baseValue; } }
final int numberOfParametersCoveredBy = getNumberOfParametersCoveredBy( ((ComponentType) type).getSubtypes() ); while ( paramIndex < numberOfParametersCoveredBy ) { final String nextToken = tokens.nextToken();
@Override public Object getIdentifier(Object entity, EntityMode entityMode, SharedSessionContractImplementor session) { final Object id = mappedIdentifierType.instantiate( entityMode ); final Object[] propertyValues = virtualIdComponent.getPropertyValues( entity, entityMode ); final Type[] subTypes = virtualIdComponent.getSubtypes(); final Type[] copierSubTypes = mappedIdentifierType.getSubtypes(); final int length = subTypes.length; for ( int i = 0; i < length; i++ ) { if ( propertyValues[i] == null ) { throw new HibernateException( "No part of a composite identifier may be null" ); } //JPA 2 @MapsId + @IdClass points to the pk of the entity if ( subTypes[i].isAssociationType() && !copierSubTypes[i].isAssociationType() ) { propertyValues[i] = determineEntityId( propertyValues[i], (AssociationType) subTypes[i], session, sessionFactory ); } } mappedIdentifierType.setPropertyValues( id, propertyValues, entityMode ); return id; }
String[] componentProperties = ((ComponentType) type).getPropertyNames(); List<String> componentPropertyNames = Arrays.asList(componentProperties); Type[] componentTypes = ((ComponentType) type).getSubtypes(); List<Type> componentPropertyTypes = Arrays.asList(componentTypes); String tempPrefix = "";
final Object[] injectionValues = new Object[extractedValues.length]; final PersistenceContext persistenceContext = session.getPersistenceContext(); for ( int i = 0; i < virtualIdComponent.getSubtypes().length; i++ ) { final Type virtualPropertyType = virtualIdComponent.getSubtypes()[i]; final Type idClassPropertyType = mappedIdentifierType.getSubtypes()[i]; if ( virtualPropertyType.isEntityType() && !idClassPropertyType.isEntityType() ) { if ( session == null ) {
knownEmbeddedtypes.add(type.getReturnedClass().getName()); String [] names = embed.getPropertyNames(); Type [] types = embed.getSubtypes(); for (int n = 0; n < names.length; n++) registerEntityField(type.getReturnedClass(), names[n], types[n]);
private void findComponentProperties(Type[] propertyTypes, Set<Class<?>> typesToRegister) { if (propertyTypes == null) { return; } for (Type propertyType : propertyTypes) { if (propertyType instanceof ComponentType) { typesToRegister.add(propertyType.getReturnedClass()); findComponentProperties(((ComponentType)propertyType).getSubtypes(), typesToRegister); } } } }
private void findComponentProperties(Type[] propertyTypes, Set<Class<?>> typesToRegister) { if (propertyTypes == null) { return; } for (Type propertyType : propertyTypes) { if (propertyType instanceof ComponentType) { typesToRegister.add(propertyType.getReturnedClass()); findComponentProperties(((ComponentType)propertyType).getSubtypes(), typesToRegister); } } } }
private void handleComponentType(ComponentType componentType, String property, String entityName) { for (int i = 0; i < componentType.getSubtypes().length; i++) { Type subtype = componentType.getSubtypes()[i]; String subProperty = property + "." + componentType.getPropertyNames()[i]; if (subtype instanceof EntityType && RiotFile.class.isAssignableFrom(subtype.getReturnedClass())) { fileQueries.add(String.format("select %1$s.id from %2$s where %1$s is not null", subProperty, entityName)); } else if (subtype.isComponentType()) { handleComponentType((ComponentType) subtype, subProperty, entityName); } } }
public ComponentType(org.hibernate.type.ComponentType componentType, TypeTranslator typeTranslator) { super( componentType ); this.componentType = componentType; this.propertySpan = componentType.getPropertyNames().length; final Type[] coreSubtypes = componentType.getSubtypes(); this.propertyTypes = new GridType[propertySpan]; for ( int i = 0 ; i < propertySpan ; i++ ) { this.propertyTypes[i] = typeTranslator.getType( coreSubtypes[i] ); } }
private void handleCollectionComponentType(ComponentType componentType, String property, String collectionProperty, String entityName) { for (int i = 0; i < componentType.getSubtypes().length; i++) { Type subtype = componentType.getSubtypes()[i]; String subProperty = property != null ? property + "." + componentType.getPropertyNames()[i] : componentType.getPropertyNames()[i]; if (subtype instanceof EntityType && RiotFile.class.isAssignableFrom(subtype.getReturnedClass())) { fileQueries.add(String.format("select file.id from %2$s ref " + "join ref.%3$s as col join col.%1$s file where file is not null", subProperty, entityName, collectionProperty)); } else if (subtype.isComponentType()) { handleCollectionComponentType((ComponentType) subtype, subProperty, collectionProperty, entityName); } } }
private Type associationPropertyType(Type type, String property) { if ( type instanceof ComponentType ) { ComponentType componentType = (ComponentType) type; return componentType.getSubtypes()[componentType.getPropertyIndex( property )]; } else if ( type instanceof EntityType ) { OgmEntityPersister persister = getPersister( type.getName() ); return persister.getPropertyType( property ); } throw new UnsupportedOperationException( "Unrecognized property type: " + type ); }
ComponentCollectionCriteriaInfoProvider(QueryableCollection persister) { this.persister = persister; if (!persister.getElementType().isComponentType()) { throw new IllegalArgumentException("persister for role "+persister.getRole()+" is not a collection-of-component"); } ComponentType componentType = (ComponentType)persister.getElementType(); String[] names = componentType.getPropertyNames(); Type[] types = componentType.getSubtypes(); for (int i = 0; i < names.length; i++) { subTypes.put(names[i], types[i]); } }
/** * {@inheritDoc} */ @Override public Type getPropertyType(String propertyName, String propertyPath) { int index = getComponentType().getPropertyIndex( propertyName ); return getComponentType().getSubtypes()[index]; }
/** * {@inheritDoc} */ @Override public Type getPropertyType(String propertyName, String propertyPath) { int index = getComponentType().getPropertyIndex( propertyName ); return getComponentType().getSubtypes()[index]; }
ComponentCollectionCriteriaInfoProvider(QueryableCollection persister) { this.persister = persister; if (!persister.getElementType().isComponentType()) { throw new IllegalArgumentException("persister for role "+persister.getRole()+" is not a collection-of-component"); } ComponentType componentType = (ComponentType)persister.getElementType(); String[] names = componentType.getPropertyNames(); Type[] types = componentType.getSubtypes(); for (int i = 0; i < names.length; i++) { subTypes.put(names[i], types[i]); } }
private void collectEmbeddedCollectionColumns(ComponentType componentType, String dotName, List<String> embeddedCollections) { for ( String propertyName : componentType.getPropertyNames() ) { Type type = componentType.getSubtypes()[componentType.getPropertyIndex( propertyName )]; if ( type.isCollectionType() ) { embeddedCollections.add( dotName + "." + propertyName ); } else if ( type.isComponentType() ) { collectEmbeddedCollectionColumns( (ComponentType) type, dotName + "." + propertyName, embeddedCollections ); } } }
public Metadata getPropertyType(String property) { if (!type.isComponentType()) return null; int i = getPropertyIndex(property); if (i == -1) { return null; } else { Type pType = ((ComponentType)type).getSubtypes()[i]; Class<?> pCollectionType = null; if (pType.isCollectionType()) { pType = ((CollectionType)pType).getElementType((SessionFactoryImplementor) sessionFactory); pCollectionType = pType.getReturnedClass(); } if (pType.isEntityType()) { return new HibernateEntityMetadata(sessionFactory, sessionFactory.getClassMetadata(((EntityType)pType).getName()), pCollectionType); } else { return new HibernateNonEntityMetadata(sessionFactory, pType, pCollectionType); } } }