in google-cloud-spanner-hibernate-dialect/src/main/java/com/google/cloud/spanner/hibernate/schema/TableDependencyTracker.java [56:83]
public void initializeDependencies(Metadata metadata, Action schemaAction) {
HashMap<Table, Table> dependencies = new HashMap<>();
for (Table childTable : metadata.collectTableMappings()) {
Class<?> entity = SchemaUtils.getEntityClass(childTable, metadata);
Interleaved interleaved = entity != null ? entity.getAnnotation(Interleaved.class) : null;
if (interleaved != null) {
if (!SchemaUtils.validateInterleaved(entity)) {
log.warnf(
"Composite key for Interleaved table '%s' should be a superset of the parent's key.",
entity.getName());
}
// Add table dependency
if (schemaAction == Action.CREATE || schemaAction == Action.UPDATE) {
// If creating tables, the parent blocks the child.
dependencies.put(childTable, SchemaUtils.getTable(interleaved.parentEntity(), metadata));
} else {
// If dropping tables, the child blocks the parent.
dependencies.put(SchemaUtils.getTable(interleaved.parentEntity(), metadata), childTable);
}
}
}
this.tableDependencies = dependencies;
this.processedTables = new HashSet<>();
}