private boolean isRowKeyColumn(AssociationKeyMetadata metadata, String column) { for ( String rowKeyColumn : metadata.getRowKeyColumnNames() ) { if ( rowKeyColumn.equals( column ) ) { return true; } } return false; }
public IgniteAssociationSnapshot(AssociationKey associationKey, Map<Object, BinaryObject> associationMap) { this.rows = CollectionHelper.newHashMap( associationMap.size() ); for ( Map.Entry<Object, BinaryObject> entry : associationMap.entrySet() ) { IgniteAssociationRowSnapshot snapshot = new IgniteAssociationRowSnapshot( entry.getKey(), entry.getValue(), associationKey.getMetadata() ); String rowKeyColumnNames[] = associationKey.getMetadata().getRowKeyColumnNames(); Object rowKeyColumnValues[] = new Object[rowKeyColumnNames.length]; for ( int i = 0; i < rowKeyColumnNames.length; i++ ) { String columnName = rowKeyColumnNames[i]; rowKeyColumnValues[i] = snapshot.get( columnName ); } RowKey rowKey = new RowKey( rowKeyColumnNames, rowKeyColumnValues ); this.rows.put( rowKey, snapshot ); } }
protected RowKey convert(AssociationKey associationKey, TupleSnapshot snapshot) { String[] columnNames = associationKey.getMetadata().getRowKeyColumnNames(); Object[] values = new Object[columnNames.length]; for ( int i = 0; i < columnNames.length; i++ ) { values[i] = snapshot.get( columnNames[i] ); } return new RowKey( columnNames, values ); }
@Override protected RowKey convert(AssociationKey associationKey, TupleSnapshot snapshot) { String[] columnNames = associationKey.getMetadata().getRowKeyColumnNames(); Object[] values = new Object[columnNames.length]; for ( int i = 0; i < columnNames.length; i++ ) { values[i] = snapshot.get( columnNames[i] ); } return new RowKey( columnNames, values ); }
private void validateAssociationNames(Iterable<AssociationKeyMetadata> allAssociationKeyMetadata) { for ( AssociationKeyMetadata associationKeyMetadata : allAssociationKeyMetadata ) { validateAsMongoDBCollectionName( associationKeyMetadata.getTable() ); for ( String column : associationKeyMetadata.getRowKeyColumnNames() ) { validateAsMongoDBFieldName( column ); } } }
private void validateAssociationNames(Iterable<AssociationKeyMetadata> allAssociationKeyMetadata) { for ( AssociationKeyMetadata associationKeyMetadata : allAssociationKeyMetadata ) { validateAsMongoDBCollectionName( associationKeyMetadata.getTable() ); for ( String column : associationKeyMetadata.getRowKeyColumnNames() ) { validateAsMongoDBFieldName( column ); } } }
private RowKey getInverseRowKey(Tuple associationRow) { String[] inverseRowKeyColumnNames = inverseCollectionPersister.getAssociationKeyMetadata().getRowKeyColumnNames(); Object[] columnValues = new Object[inverseRowKeyColumnNames.length]; for ( int i = 0; i < inverseRowKeyColumnNames.length; i++ ) { columnValues[i] = associationRow.get( inverseRowKeyColumnNames[i] ); } return new RowKey( inverseRowKeyColumnNames, columnValues ); }
private RowKey convert(AssociationKey associationKey, RemoteNeo4jTupleAssociationSnapshot snapshot) { String[] columnNames = associationKey.getMetadata().getRowKeyColumnNames(); Object[] values = new Object[columnNames.length]; for ( int i = 0; i < columnNames.length; i++ ) { values[i] = snapshot.get( columnNames[i] ); } return new RowKey( columnNames, values ); }
public RowKey asRowKey(AssociationKey key) { String[] columnNames = key.getMetadata().getRowKeyColumnNames(); Object[] columnValues = new Object[columnNames.length]; for ( int i = 0; i < columnNames.length; i++ ) { String columnName = columnNames[i]; columnValues[i] = getColumnValue( columnName ); } return new RowKey( columnNames, columnValues ); }
public IgniteAssociationRowSnapshot(Object id, BinaryObject binaryObject, AssociationKeyMetadata associationMetadata) { this.id = id; this.binaryObject = binaryObject; this.associationMetadata = associationMetadata; this.thirdTableLink = IgniteAssociationSnapshot.isThirdTableAssociation( associationMetadata ); if ( this.thirdTableLink ) { Set<String> cn = new HashSet<>(); Collections.addAll( cn, associationMetadata.getRowKeyColumnNames() ); Collections.addAll( cn, associationMetadata.getAssociatedEntityKeyMetadata().getAssociationKeyColumns() ); this.columnNames = Collections.unmodifiableSet( cn ); this.isSimpleId = true; //vk: not used in this case } else { Set<String> idColumnNames = new HashSet<>(); EntityKeyMetadata entityKeyMetadata = associationMetadata.getAssociatedEntityKeyMetadata().getEntityKeyMetadata(); for ( String columnName : entityKeyMetadata.getColumnNames() ) { if ( entityKeyMetadata.isKeyColumn( columnName ) ) { idColumnNames.add( columnName ); } } if ( idColumnNames.isEmpty() ) { throw new UnsupportedOperationException( "There is no id column in entity " + entityKeyMetadata.getTable() + ". Hmm..." ); } this.columnNames = CollectionHelper.asSet( entityKeyMetadata.getColumnNames() ); this.isSimpleId = idColumnNames.size() == 1; } }
private void appendIndex(QueryEntity queryEntity, AssociationKeyMetadata associationKeyMetadata, SchemaDefinitionContext context) { QueryIndex queryIndex = new QueryIndex(); queryIndex.setIndexType( QueryIndexType.SORTED ); LinkedHashMap<String, Boolean> fields = new LinkedHashMap<>(); for ( String columnName : associationKeyMetadata.getRowKeyColumnNames() ) { String realColumnName = StringHelper.realColumnName( columnName ); queryEntity.addQueryField( realColumnName, STRING_CLASS_NAME, null ); //vk: why always String here? fields.put( realColumnName, true ); } queryIndex.setFields( fields ); queryIndex.setName( queryEntity.getTableName() + '_' + org.hibernate.ogm.util.impl.StringHelper.join( fields.keySet(), "_" ) ); Set<QueryIndex> indexes = new HashSet<>( queryEntity.getIndexes() ); indexes.add( queryIndex ); queryEntity.setIndexes( indexes ); }
public IgniteEmbeddedAssociationSnapshot(AssociationKey associationKey, Tuple tuple) { this.associationMetadata = associationKey.getMetadata(); this.tuple = tuple; BinaryObject obj = ( (IgniteTupleSnapshot) tuple.getSnapshot() ).getCacheValue(); Object objects[] = obj != null ? (Object[]) obj.field( StringHelper.realColumnName( associationMetadata.getCollectionRole() ) ) : null; rows = new HashMap<>(); if ( objects != null ) { String rowKeyColumnNames[] = new String[ associationMetadata.getRowKeyColumnNames().length ]; for ( int i = 0; i < rowKeyColumnNames.length; i++ ) { rowKeyColumnNames[i] = StringHelper.stringAfterPoint( associationMetadata.getRowKeyColumnNames()[i] ); } for ( int i = 0; i < objects.length; i++ ) { BinaryObject itemObject = (BinaryObject) objects[i]; Object rowKeyColumnValues[] = new Object[rowKeyColumnNames.length]; for ( int j = 0; j < rowKeyColumnNames.length; j++ ) { rowKeyColumnValues[j] = itemObject.field( rowKeyColumnNames[j] ); } RowKey rowKey = new RowKey( associationMetadata.getRowKeyColumnNames(), rowKeyColumnValues ); this.rows.put( rowKey, new IgniteTupleSnapshot( null, itemObject, associationMetadata.getAssociatedEntityKeyMetadata().getEntityKeyMetadata() ) ); } } }
String[] rowKeyColumnNames = associationKey.getMetadata().getRowKeyColumnNames();
/** * Creates the row key of the given association row; columns present in the given association key will be obtained * from there, all other columns from the given native association row. */ private static <R> RowKey buildRowKey(AssociationKey associationKey, R row, AssociationRowAccessor<R> accessor) { String[] columnNames = associationKey.getMetadata().getRowKeyColumnNames(); Object[] columnValues = new Object[columnNames.length]; for ( int i = 0; i < columnNames.length; i++ ) { String columnName = columnNames[i]; columnValues[i] = associationKey.getMetadata().isKeyColumn( columnName ) ? associationKey.getColumnValue( columnName ) : accessor.get( row, columnName ); } return new RowKey( columnNames, columnValues ); }
private static Map<String, Object> collectProperties(Relationship relationship, AssociationKey associationKey, AssociatedEntityKeyMetadata associatedEntityKeyMetadata) { Map<String, Object> properties = new HashMap<String, Object>(); String[] rowKeyColumnNames = associationKey.getMetadata().getRowKeyColumnNames();
/** * Gets the row key of the inverse association represented by the given meta-data, pointing the entity with current * {@link EntityAssociationUpdater#id} * * @param associationKeyMetadata meta-data for the inverse association of interest * @param associationColumnValues the column values identifying the entity on the inverse side of the association * @return the row key of the inverse association */ private RowKey getInverseRowKey(AssociationKeyMetadata associationKeyMetadata, Object[] associationColumnValues) { Tuple rowKeyValues = new Tuple(); // add the fk column for ( int index = 0; index < associationKeyMetadata.getColumnNames().length; index++ ) { rowKeyValues.put( associationKeyMetadata.getColumnNames()[index], associationColumnValues[index] ); } // add the id column persister.getGridIdentifierType().nullSafeSet( rowKeyValues, id, persister.getIdentifierColumnNames(), session ); return new RowKeyBuilder() .addColumns( associationKeyMetadata.getRowKeyColumnNames() ) .values( rowKeyValues ) .build(); }
if ( clearBo != null ) { BinaryObjectBuilder clearBoBuilder = provider.createBinaryObjectBuilder( clearBo ); for ( String columnName : key.getMetadata().getRowKeyColumnNames() ) { clearBoBuilder.removeField( StringHelper.realColumnName( columnName ) );