[jOOQ/jOOQ#6124] Fixed mix up between defining and referencing columns

This commit is contained in:
Lukas Eder 2020-08-19 16:36:47 +02:00
parent 80ed6c76d5
commit 8be5e78a0f
3 changed files with 35 additions and 5 deletions

View File

@ -5298,7 +5298,8 @@ public class JavaGenerator extends AbstractGenerator {
protected void generateEmbeddables(SchemaDefinition schema) {
log.info("Generating embeddables");
for (EmbeddableDefinition embeddable : database.getEmbeddables(schema)) {
// [#6124] Prevent FKs from overriding PK embeddable
for (EmbeddableDefinition embeddable : new LinkedHashSet<>(database.getEmbeddables(schema))) {
try {
// [#6124] [#10481] Don't generate embeddable types for FKs

View File

@ -142,6 +142,25 @@ public class DefaultEmbeddableDefinition
return getElement(columnIndex);
}
@Override
public final EmbeddableColumnDefinition getReferencingColumn(String columnName) {
return getReferencingColumn(columnName, false);
}
@Override
public final EmbeddableColumnDefinition getReferencingColumn(String columnName, boolean ignoreCase) {
if (columnName == null)
return null;
for (EmbeddableColumnDefinition column : getColumns())
if ((ignoreCase && column.getReferencingColumn().getName().equalsIgnoreCase(columnName)) ||
(!ignoreCase && column.getReferencingColumn().getName().equals(columnName)))
return column;
return null;
}
@Override
public final boolean replacesFields() {
return replacesFields;

View File

@ -76,25 +76,35 @@ public interface EmbeddableDefinition extends TableElementDefinition {
TableDefinition getReferencingTable();
/**
* All referencing columns in the type, table or view.
* All defining columns in the type, table or view.
*/
List<EmbeddableColumnDefinition> getColumns();
/**
* Get a referencing column in this type by its name.
* Get a defining column in this type by its name.
*/
EmbeddableColumnDefinition getColumn(String columnName);
/**
* Get a referencing column in this type by its name.
* Get a defining column in this type by its name.
*/
EmbeddableColumnDefinition getColumn(String columnName, boolean ignoreCase);
/**
* Get a referencing column in this type by its index (starting at 0).
* Get a defining column in this type by its index (starting at 0).
*/
EmbeddableColumnDefinition getColumn(int columnIndex);
/**
* Get a referencing column in this type by its referencing name.
*/
EmbeddableColumnDefinition getReferencingColumn(String columnName);
/**
* Get a referencing column in this type by its referencing name.
*/
EmbeddableColumnDefinition getReferencingColumn(String columnName, boolean ignoreCase);
/**
* Whether this embeddable replaces the fields it represents.
*/