private int findSubPropertyIndex(ComponentType type, String subPropertyName) { final String[] propertyNames = type.getPropertyNames(); for ( int index = 0; index < propertyNames.length; index++ ) { if ( subPropertyName.equals( propertyNames[index] ) ) { return index; } } throw new MappingException( "component property not found: " + subPropertyName ); }
@Override public int getPropertyIndex(String name) { String[] names = getPropertyNames(); for ( int i = 0, max = names.length; i < max; i++ ) { if ( names[i].equals( name ) ) { return i; } } throw new PropertyNotFoundException( "Unable to locate property named " + name + " on " + getReturnedClass().getName() ); }
String prefix, String parentPrefix) { String[] componentProperties = ((ComponentType) type).getPropertyNames(); List<String> componentPropertyNames = Arrays.asList(componentProperties); Type[] componentTypes = ((ComponentType) type).getSubtypes();
for ( int i = 0; i < componentType.getPropertyNames().length; i++ ) { final Object componentValue = componentType.getPropertyValue( value, i, session ); parameters.addWhereWithParam( alias, propertyName + "_" + componentType.getPropertyNames()[ i ], op, componentValue
virtualIdComponent.getPropertyNames()[i] );
ComponentType embed = (ComponentType)type; knownEmbeddedtypes.add(type.getReturnedClass().getName()); String [] names = embed.getPropertyNames(); Type [] types = embed.getSubtypes(); for (int n = 0; n < names.length; n++)
private int findSubPropertyIndex(ComponentType type, String subPropertyName) { final String[] propertyNames = type.getPropertyNames(); for ( int index = 0; index<propertyNames.length; index++ ) { if ( subPropertyName.equals( propertyNames[index] ) ) { return index; } } throw new MappingException( "component property not found: " + subPropertyName ); }
public String[] getProperties() { if (type.isComponentType()) return ((ComponentType)type).getPropertyNames(); else return null; }
private int findSubPropertyIndex(ComponentType type, String subPropertyName) { final String[] propertyNames = type.getPropertyNames(); for ( int index = 0; index<propertyNames.length; index++ ) { if ( subPropertyName.equals( propertyNames[index] ) ) { return index; } } throw new MappingException( "component property not found: " + subPropertyName ); }
public int getPropertyIndex(String name) { String[] names = getPropertyNames(); for ( int i = 0, max = names.length; i < max; i++ ) { if ( names[i].equals( name ) ) { return i; } } throw new PropertyNotFoundException( "Unable to locate property named " + name + " on " + getReturnedClass().getName() ); } }
public int getPropertyIndex(String name) { String[] names = getPropertyNames(); for ( int i = 0, max = names.length; i < max; i++ ) { if ( names[i].equals( name ) ) { return i; } } throw new PropertyNotFoundException( "Unable to locate property named " + name + " on " + getReturnedClass().getName() ); } }
public CompositeIdOrder(String componentPath, ComponentType componentType) { super(); this.componentType = componentType; // Initialize with relative paths, but prepend a prefix below this.propertyPaths = new ArrayList<>( Arrays.asList( componentType.getPropertyNames() ) ); this.propertyPaths.sort( Comparator.naturalOrder() ); String pathPrefix = componentPath == null ? "" : componentPath + "."; this.propertyIndices = CollectionHelper.newArrayList( propertyPaths.size() ); ListIterator<String> iterator = this.propertyPaths.listIterator(); while ( iterator.hasNext() ) { String propertyName = iterator.next(); // We need the relative path of the property here propertyIndices.add( componentType.getPropertyIndex( propertyName ) ); // Prepend the path prefix to each property; we will only use absolute path from now on iterator.set( pathPrefix + propertyName ); } }
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 boolean isColumnShared(AbstractEntityPersister subclassPersister, String[] columnNames) { List<String> propertiesToCheck = new ArrayList<>(Arrays.asList(subclassPersister.getPropertyNames())); while (!propertiesToCheck.isEmpty()) { String propertyName = propertiesToCheck.remove(propertiesToCheck.size() - 1); Type propertyType = subclassPersister.getPropertyType(propertyName); if (propertyType instanceof ComponentType) { ComponentType componentType = (ComponentType) propertyType; for (String subPropertyName : componentType.getPropertyNames()) { propertiesToCheck.add(propertyName + "." + subPropertyName); } } else { String[] subclassColumnNames = subclassPersister.getSubclassPropertyColumnNames(propertyName); if (Arrays.deepEquals(columnNames, subclassColumnNames)) { return true; } } } return false; }
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); } } }
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 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); } } }
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 ); } } }
private void collectPropertyNames(Collection<String> propertyNames, String prefix, Type propertyType, Mapping factory) { if (propertyType instanceof ComponentType) { ComponentType componentType = (ComponentType) propertyType; for (String propertyName : componentType.getPropertyNames()) { Type subtype = componentType.getSubtypes()[componentType.getPropertyIndex(propertyName)]; collectPropertyNames(propertyNames, prefix == null ? propertyName : prefix + "." + propertyName, subtype, factory); } } else if (propertyType instanceof org.hibernate.type.EntityType) { org.hibernate.type.EntityType entityType = (org.hibernate.type.EntityType) propertyType; Type identifierOrUniqueKeyType = entityType.getIdentifierOrUniqueKeyType(factory); if (identifierOrUniqueKeyType instanceof EmbeddedComponentType) { EmbeddedComponentType embeddedComponentType = (EmbeddedComponentType) identifierOrUniqueKeyType; for (String propertyName : embeddedComponentType.getPropertyNames()) { propertyNames.add(prefix == null ? propertyName : prefix + "." + propertyName); } } else { String identifierOrUniqueKeyPropertyName = entityType.getIdentifierOrUniqueKeyPropertyName(factory); propertyNames.add(prefix == null ? identifierOrUniqueKeyPropertyName : prefix + "." + identifierOrUniqueKeyPropertyName); } } else if (!(propertyType instanceof CollectionType) && prefix != null) { propertyNames.add(prefix); } }