public AbstractLoadPlanBasedCollectionInitializer( QueryableCollection collectionPersister, QueryBuildingParameters buildingParameters) { super( collectionPersister.getFactory() ); this.collectionPersister = collectionPersister; this.lockOptions = buildingParameters.getLockMode() != null ? new LockOptions( buildingParameters.getLockMode() ) : buildingParameters.getLockOptions(); final FetchStyleLoadPlanBuildingAssociationVisitationStrategy strategy = new FetchStyleLoadPlanBuildingAssociationVisitationStrategy( collectionPersister.getFactory(), buildingParameters.getQueryInfluencers(), this.lockOptions.getLockMode() ); final LoadPlan plan = MetamodelDrivenLoadPlanBuilder.buildRootCollectionLoadPlan( strategy, collectionPersister ); this.staticLoadQuery = BatchingLoadQueryDetailsFactory.INSTANCE.makeCollectionLoadQueryDetails( collectionPersister, plan, buildingParameters ); }
@Override public List<String> getIdentifierOrUniqueKeyEmbeddedPropertyNames(EntityType<?> owner, String elementCollectionPath, String attributeName) { QueryableCollection persister = getCollectionPersister(owner, elementCollectionPath); ComponentType componentType = (ComponentType) persister.getElementType(); String subAttribute = attributeName.substring(elementCollectionPath.length() + 1); // Component types only store direct properties, so we have to go deeper String[] propertyParts = subAttribute.split("\\."); Type propertyType; for (int i = 0; i < propertyParts.length - 1; i++) { int index = componentType.getPropertyIndex(propertyParts[i]); propertyType = componentType.getSubtypes()[index]; if (propertyType instanceof ComponentType) { componentType = (ComponentType) propertyType; } else { // A path expression shouldn't navigate over an association.. throw new IllegalStateException("Can't get the id properties for: " + attributeName); } } propertyType = componentType.getSubtypes()[componentType.getPropertyIndex(propertyParts[propertyParts.length - 1])]; List<String> identifierOrUniqueKeyPropertyNames = new ArrayList<>(); collectPropertyNames(identifierOrUniqueKeyPropertyNames, null, propertyType, persister.getFactory()); return identifierOrUniqueKeyPropertyNames; }
} else { keyColumnMapping.put(indexColumnNames[0], indexColumnNames[0]); keyColumnTypes.put(indexColumnNames[0], getColumnTypeForPropertyType(ownerType, attributeName, queryableCollection.getFactory(), queryableCollection.getIndexType())[0]); if (elementType instanceof ComponentType) { targetIdAttributeNames = new HashSet<>(); collectPropertyNames(targetIdAttributeNames, null, elementType, queryableCollection.getFactory());
int span = subtypes[i].getColumnSpan(persister.getFactory()); if (propertyName.equals(propertyNames[i])) { if (subtypes[i] instanceof ComponentType) { int span = subtypes[i].getColumnSpan(persister.getFactory()); if (propertyName.equals(propertyNames[i])) { String[] columnNames = new String[span]; Type identifierType = ((org.hibernate.type.EntityType) persister.getElementType()).getIdentifierOrUniqueKeyType(persister.getFactory()); String identifierOrUniqueKeyPropertyName = ((org.hibernate.type.EntityType) persister.getElementType()).getIdentifierOrUniqueKeyPropertyName(persister.getFactory()); String prefix; if (identifierType instanceof EmbeddedComponentType) { String[] propertyNames = ((EmbeddedComponentType) identifierType).getPropertyNames(); String[] columnNames = columnNamesByPropertyName(elementPersister, propertyNames, subAttributeName, "", persister.getElementColumnNames(), persister.getFactory()); if (columnNames != null) { return columnNames; } else if (identifierType instanceof ComponentType && subAttributeName.startsWith(prefix = identifierOrUniqueKeyPropertyName + ".")) { String[] propertyNames = ((ComponentType) identifierType).getPropertyNames(); String[] columnNames = columnNamesByPropertyName(elementPersister, propertyNames, subAttributeName.substring(identifierOrUniqueKeyPropertyName.length() + 1), prefix, persister.getElementColumnNames(), persister.getFactory()); if (columnNames != null) { return columnNames;
@Override public String[] getColumnTypes(EntityType<?> ownerType, String elementCollectionPath, String attributeName) { QueryableCollection persister = getCollectionPersister(ownerType, elementCollectionPath); SessionFactoryImplementor sfi = persister.getFactory(); String[] columnNames = null; Type propertyType = null; int span = subtypes[i].getColumnSpan(persister.getFactory()); if (propertyName.equals(propertyNames[i])) { if (subtypes[i] instanceof ComponentType) { String propertyName = propertyParts[propertyParts.length - 1]; for (int i = 0; i < propertyNames.length; i++) { int span = subtypes[i].getColumnSpan(persister.getFactory()); if (propertyName.equals(propertyNames[i])) { columnNames = new String[span]; Type identifierType = ((org.hibernate.type.EntityType) persister.getElementType()).getIdentifierOrUniqueKeyType(persister.getFactory()); String identifierOrUniqueKeyPropertyName = ((org.hibernate.type.EntityType) persister.getElementType()).getIdentifierOrUniqueKeyPropertyName(persister.getFactory()); String prefix; if (identifierType instanceof EmbeddedComponentType) { for (int i = 0; i < propertyNames.length; i++) { String propertyName = propertyNames[i]; int span = subtypes[i].getColumnSpan(persister.getFactory()); if (subAttributeName.equals(propertyName)) { columnNames = new String[span]; for (int i = 0; i < propertyNames.length; i++) { String propertyName = propertyNames[i];
SessionFactoryImplementor sfi = collectionPersister.getFactory(); return getColumnTypeForPropertyType(entityType, attributeName, sfi, collectionPersister.getElementType());