From 005b1c61fdfbddcb6250d3bb2db42ce92cc5ad0b Mon Sep 17 00:00:00 2001 From: fanste Date: Wed, 3 Jul 2024 09:51:17 +0200 Subject: [PATCH] HBX-2823: Fix foreign key generation Virtual foreign keys defined in the reveng XML are not correctly created in the generated model. --- .../internal/reveng/reader/ForeignKeyProcessor.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/orm/src/main/java/org/hibernate/tool/internal/reveng/reader/ForeignKeyProcessor.java b/orm/src/main/java/org/hibernate/tool/internal/reveng/reader/ForeignKeyProcessor.java index 445e3317c1..55548f45fc 100644 --- a/orm/src/main/java/org/hibernate/tool/internal/reveng/reader/ForeignKeyProcessor.java +++ b/orm/src/main/java/org/hibernate/tool/internal/reveng/reader/ForeignKeyProcessor.java @@ -244,10 +244,9 @@ private void processUserForeignKey( " references unknown or filtered table " + TableIdentifier.create(element.getTable()) ); } else { - dependentTables.put(element.getName(), deptable); - List refColumns = getReferencedColums(referencedTable, element); - referencedColumns.put(element.getName(), refColumns ); - dependentColumns.put(element.getName(), getDependendColumns(refColumns, deptable) ); + dependentTables.put(element.getName(), deptable); + referencedColumns.put(element.getName(), getReferencedColums(referencedTable, element) ); + dependentColumns.put(element.getName(), getDependendColumns(deptable, element) ); } } @@ -264,7 +263,8 @@ private Table determineDependentTable(Map dependentTables, Foreig userfkTable.getName()); } - private List getDependendColumns(List userColumns, Table deptable) { + private List getDependendColumns(Table deptable, ForeignKey element) { + List userColumns = element.getColumns(); List depColumns = new ArrayList(userColumns.size() ); Iterator colIterator = userColumns.iterator(); while(colIterator.hasNext() ) {