Search in sources :

Example 1 with Definition

use of org.jooq.meta.Definition in project jOOQ by jOOQ.

the class JavaGenerator method generateDao.

protected void generateDao(TableDefinition table, JavaWriter out) {
    UniqueKeyDefinition key = table.getPrimaryKey();
    if (key == null) {
        log.info("Skipping DAO generation", out.file().getName());
        return;
    }
    final String className = getStrategy().getJavaClassName(table, Mode.DAO);
    final List<String> interfaces = out.ref(getStrategy().getJavaClassImplements(table, Mode.DAO));
    final String tableRecord = out.ref(getStrategy().getFullJavaClassName(table, Mode.RECORD));
    final String daoImpl = out.ref(DAOImpl.class);
    final String tableIdentifier = out.ref(getStrategy().getFullJavaIdentifier(table), 2);
    String tType = (scala || kotlin ? "Unit" : "Void");
    String pType = out.ref(getStrategy().getFullJavaClassName(table, Mode.POJO));
    List<ColumnDefinition> keyColumns = key.getKeyColumns();
    if (keyColumns.size() == 1) {
        tType = getJavaType(keyColumns.get(0).getType(resolver(out)), out, Mode.POJO);
    } else if (keyColumns.size() <= Constants.MAX_ROW_DEGREE) {
        StringBuilder generics = new StringBuilder();
        forEach(keyColumns, "", ", ", (column, separator) -> {
            generics.append(out.ref(getJavaType(column.getType(resolver(out)), out)));
            if (kotlin)
                generics.append("?");
            generics.append(separator);
        });
        if (scala)
            tType = Record.class.getName() + keyColumns.size() + "[" + generics + "]";
        else
            tType = Record.class.getName() + keyColumns.size() + "<" + generics + ">";
    } else {
        tType = Record.class.getName();
    }
    tType = out.ref(tType);
    printPackage(out, table, Mode.DAO);
    generateDaoClassJavadoc(table, out);
    printClassAnnotations(out, table, Mode.DAO);
    if (generateSpringAnnotations())
        out.println("@%s", out.ref("org.springframework.stereotype.Repository"));
    if (scala)
        out.println("%sclass %s(configuration: %s) extends %s[%s, %s, %s](%s, classOf[%s], configuration)[[before= with ][separator= with ][%s]] {", visibility(), className, Configuration.class, daoImpl, tableRecord, pType, tType, tableIdentifier, pType, interfaces);
    else if (kotlin)
        out.println("%sopen class %s(configuration: %s?) : %s<%s, %s, %s>(%s, %s::class.java, configuration)[[before=, ][%s]] {", visibility(), className, Configuration.class, daoImpl, tableRecord, pType, tType, tableIdentifier, pType, interfaces);
    else
        out.println("%sclass %s extends %s<%s, %s, %s>[[before= implements ][%s]] {", visibility(), className, daoImpl, tableRecord, pType, tType, interfaces);
    // Default constructor
    // -------------------
    out.javadoc("Create a new %s without any configuration", className);
    if (scala) {
        out.println("%sdef this() = this(null)", visibility());
    } else if (kotlin) {
        out.println("%sconstructor(): this(null)", visibility());
    } else {
        out.println("%s%s() {", visibility(), className);
        out.println("super(%s, %s.class);", tableIdentifier, pType);
        out.println("}");
    }
    if (!scala && !kotlin) {
        out.javadoc("Create a new %s with an attached configuration", className);
        printDaoConstructorAnnotations(table, out);
        out.println("%s%s(%s configuration) {", visibility(), className, Configuration.class);
        out.println("super(%s, %s.class, configuration);", tableIdentifier, pType);
        out.println("}");
    }
    // -------------------------------
    if (scala) {
        out.println();
        out.print("%soverride def getId(o: %s): %s = ", visibilityPublic(), pType, tType);
    } else if (kotlin) {
        out.println();
        out.print("%soverride fun getId(o: %s): %s? = ", visibilityPublic(), pType, tType);
    } else {
        out.overrideInherit();
        printNonnullAnnotation(out);
        out.println("%s%s getId(%s object) {", visibilityPublic(), tType, pType);
    }
    if (keyColumns.size() == 1) {
        if (scala)
            out.println("o.%s", getStrategy().getJavaGetterName(keyColumns.get(0), Mode.POJO));
        else if (kotlin)
            out.println("o.%s", getStrategy().getJavaMemberName(keyColumns.get(0), Mode.POJO));
        else
            out.println("return object.%s();", generatePojosAsJavaRecordClasses() ? getStrategy().getJavaMemberName(keyColumns.get(0), Mode.POJO) : getStrategy().getJavaGetterName(keyColumns.get(0), Mode.POJO));
    } else // [#2574] This should be replaced by a call to a method on the target table's Key type
    {
        StringBuilder params = new StringBuilder();
        forEach(keyColumns, "", ", ", (column, separator) -> {
            if (scala)
                params.append("o.").append(getStrategy().getJavaGetterName(column, Mode.POJO));
            else if (kotlin)
                params.append("o.").append(getStrategy().getJavaMemberName(column, Mode.POJO));
            else
                params.append("object.").append(generatePojosAsJavaRecordClasses() ? getStrategy().getJavaMemberName(column, Mode.POJO) : getStrategy().getJavaGetterName(column, Mode.POJO)).append("()");
            params.append(separator);
        });
        if (scala || kotlin)
            out.println("compositeKeyRecord(%s)", params.toString());
        else
            out.println("return compositeKeyRecord(%s);", params.toString());
    }
    if (scala || kotlin) {
    } else
        out.println("}");
    List<Definition> embeddablesAndUnreplacedColumns = embeddablesAndUnreplacedColumns(table);
    for (Definition column : embeddablesAndUnreplacedColumns) {
        final String colName = column.getOutputName();
        final String colClass = getStrategy().getJavaClassName(column);
        final String colMemberUC = StringUtils.toUC(getStrategy().getJavaMemberName(column), getStrategy().getTargetLocale());
        final String colTypeFull = getJavaType(column, out, Mode.POJO);
        final String colTypeRecord = out.ref(getJavaType(column, out, Mode.RECORD));
        final String colType = out.ref(colTypeFull);
        final String colIdentifier = out.ref(getStrategy().getFullJavaIdentifier(column), colRefSegments(column));
        // -----------------------
        if (!printDeprecationIfUnknownType(out, colTypeFull))
            out.javadoc("Fetch records that have <code>%s BETWEEN lowerInclusive AND upperInclusive</code>", colName);
        if (scala) {
            if (column instanceof EmbeddableDefinition)
                out.println("%sdef fetchRangeOf%s(lowerInclusive: %s, upperInclusive: %s): %s[%s] = fetchRange(%s, new %s(lowerInclusive), new %s(upperInclusive))", visibility(), colMemberUC, colType, colType, List.class, pType, colIdentifier, colTypeRecord, colTypeRecord);
            else
                out.println("%sdef fetchRangeOf%s(lowerInclusive: %s, upperInclusive: %s): %s[%s] = fetchRange(%s, lowerInclusive, upperInclusive)", visibility(), colClass, colType, colType, List.class, pType, colIdentifier);
        } else if (kotlin) {
            if (column instanceof EmbeddableDefinition)
                out.println("%sfun fetchRangeOf%s(lowerInclusive: %s?, upperInclusive: %s?): %s<%s> = fetchRange(%s, if (lowerInclusive != null) %s(lowerInclusive) else null, if (upperInclusive != null) %s(upperInclusive) else null)", visibility(), colMemberUC, colType, colType, out.ref(KLIST), pType, colIdentifier, colTypeRecord, colTypeRecord);
            else
                out.println("%sfun fetchRangeOf%s(lowerInclusive: %s?, upperInclusive: %s?): %s<%s> = fetchRange(%s, lowerInclusive, upperInclusive)", visibility(), colClass, colType, colType, out.ref(KLIST), pType, colIdentifier);
        } else {
            printNonnullAnnotation(out);
            if (column instanceof EmbeddableDefinition) {
                out.println("%s%s<%s> fetchRangeOf%s(%s lowerInclusive, %s upperInclusive) {", visibility(), List.class, pType, colMemberUC, colType, colType);
                out.println("return fetchRange(%s, new %s(lowerInclusive), new %s(upperInclusive));", colIdentifier, colTypeRecord, colTypeRecord);
            } else {
                out.println("%s%s<%s> fetchRangeOf%s(%s lowerInclusive, %s upperInclusive) {", visibility(), List.class, pType, colClass, colType, colType);
                out.println("return fetchRange(%s, lowerInclusive, upperInclusive);", colIdentifier);
            }
            out.println("}");
        }
        // -----------------------
        if (!printDeprecationIfUnknownType(out, colTypeFull))
            out.javadoc("Fetch records that have <code>%s IN (values)</code>", colName);
        if (scala) {
            if (column instanceof EmbeddableDefinition)
                out.println("%sdef fetchBy%s(values: %s*): %s[%s] = fetch(%s, values.map(v => new %s(v)).toArray:_*)", visibility(), colMemberUC, colType, List.class, pType, colIdentifier, colTypeRecord);
            else
                out.println("%sdef fetchBy%s(values: %s*): %s[%s] = fetch(%s, values:_*)", visibility(), colClass, colType, List.class, pType, colIdentifier);
        } else if (kotlin) {
            String toTypedArray = PRIMITIVE_WRAPPERS.contains(colTypeFull) ? ".toTypedArray()" : "";
            if (column instanceof EmbeddableDefinition)
                out.println("%sfun fetchBy%s(vararg values: %s): %s<%s> = fetch(%s, values.map { %s(it) })", visibility(), colMemberUC, colType, out.ref(KLIST), pType, colIdentifier, colTypeRecord);
            else
                out.println("%sfun fetchBy%s(vararg values: %s): %s<%s> = fetch(%s, *values%s)", visibility(), colClass, colType, out.ref(KLIST), pType, colIdentifier, toTypedArray);
        } else {
            printNonnullAnnotation(out);
            if (column instanceof EmbeddableDefinition) {
                out.println("%s%s<%s> fetchBy%s(%s... values) {", visibility(), List.class, pType, colMemberUC, colType);
                out.println("%s[] records = new %s[values.length];", colTypeRecord, colTypeRecord);
                out.println();
                out.println("for (int i = 0; i < values.length; i++)");
                out.tab(1).println("records[i] = new %s(values[i]);", colTypeRecord);
                out.println();
                out.println("return fetch(%s, records);", colIdentifier);
            } else {
                out.println("%s%s<%s> fetchBy%s(%s... values) {", visibility(), List.class, pType, colClass, colType);
                out.println("return fetch(%s, values);", colIdentifier);
            }
            out.println("}");
        }
        // -----------------------
        ukLoop: if (column instanceof ColumnDefinition) {
            for (UniqueKeyDefinition uk : ((ColumnDefinition) column).getKeys()) {
                // If column is part of a single-column unique key...
                if (uk.getKeyColumns().size() == 1 && uk.getKeyColumns().get(0).equals(column)) {
                    if (!printDeprecationIfUnknownType(out, colTypeFull))
                        out.javadoc("Fetch a unique record that has <code>%s = value</code>", colName);
                    if (scala) {
                        out.println("%sdef fetchOneBy%s(value: %s): %s = fetchOne(%s, value)", visibility(), colClass, colType, pType, colIdentifier);
                    } else if (kotlin) {
                        out.println("%sfun fetchOneBy%s(value: %s): %s? = fetchOne(%s, value)", visibility(), colClass, colType, pType, colIdentifier);
                    } else {
                        printNullableAnnotation(out);
                        out.println("%s%s fetchOneBy%s(%s value) {", visibility(), pType, colClass, colType);
                        out.println("return fetchOne(%s, value);", colIdentifier);
                        out.println("}");
                        if (!printDeprecationIfUnknownType(out, colTypeFull))
                            out.javadoc("Fetch a unique record that has <code>%s = value</code>", colName);
                        printNonnullAnnotation(out);
                        out.println("%s%s<%s> fetchOptionalBy%s(%s value) {", visibility(), Optional.class, pType, colClass, colType);
                        out.println("return fetchOptional(%s, value);", colIdentifier);
                        out.println("}");
                    }
                    break ukLoop;
                }
            }
        }
    }
    generateDaoClassFooter(table, out);
    out.println("}");
}
Also used : RandomAccessFile(java.io.RandomAccessFile) Arrays(java.util.Arrays) TableRecordImpl(org.jooq.impl.TableRecordImpl) DSL(org.jooq.impl.DSL) SCALA(org.jooq.codegen.Language.SCALA) StringUtils.isBlank(org.jooq.tools.StringUtils.isBlank) Collectors.counting(java.util.stream.Collectors.counting) Internal(org.jooq.impl.Internal) POSTGRES(org.jooq.SQLDialect.POSTGRES) DatatypeConverter(jakarta.xml.bind.DatatypeConverter) AttributeDefinition(org.jooq.meta.AttributeDefinition) ColumnDefinition(org.jooq.meta.ColumnDefinition) RoutineDefinition(org.jooq.meta.RoutineDefinition) Matcher(java.util.regex.Matcher) IndexColumnDefinition(org.jooq.meta.IndexColumnDefinition) SelectField(org.jooq.SelectField) IdentityDefinition(org.jooq.meta.IdentityDefinition) Arrays.asList(java.util.Arrays.asList) Index(org.jooq.Index) Map(java.util.Map) BigInteger(java.math.BigInteger) SQLDialect(org.jooq.SQLDialect) Domain(org.jooq.Domain) Database(org.jooq.meta.Database) EmbeddableColumnDefinition(org.jooq.meta.EmbeddableColumnDefinition) CheckConstraintDefinition(org.jooq.meta.CheckConstraintDefinition) Set(java.util.Set) Constants(org.jooq.Constants) AggregateFunction(org.jooq.AggregateFunction) Result(org.jooq.Result) Collectors.joining(java.util.stream.Collectors.joining) GenerationOption(org.jooq.impl.QOM.GenerationOption) Stream(java.util.stream.Stream) TableField(org.jooq.TableField) SQLDataType(org.jooq.impl.SQLDataType) GeneratedAnnotationType(org.jooq.meta.jaxb.GeneratedAnnotationType) SequenceDefinition(org.jooq.meta.SequenceDefinition) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) Parameter(org.jooq.Parameter) TableDefinition(org.jooq.meta.TableDefinition) CatalogImpl(org.jooq.impl.CatalogImpl) IndexDefinition(org.jooq.meta.IndexDefinition) Sequence(org.jooq.Sequence) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Calendar(java.util.Calendar) Records(org.jooq.Records) Schema(org.jooq.Schema) BiConsumer(java.util.function.BiConsumer) RowId(org.jooq.RowId) LinkedHashSet(java.util.LinkedHashSet) MYSQL(org.jooq.SQLDialect.MYSQL) Record(org.jooq.Record) Mode(org.jooq.codegen.GeneratorStrategy.Mode) TypeVariable(java.lang.reflect.TypeVariable) IOException(java.io.IOException) StringUtils(org.jooq.tools.StringUtils) File(java.io.File) YUGABYTEDB(org.jooq.SQLDialect.YUGABYTEDB) VIRTUAL(org.jooq.impl.QOM.GenerationOption.VIRTUAL) SchemaDefinition(org.jooq.meta.SchemaDefinition) LazySupplier(org.jooq.impl.LazySupplier) TableImpl(org.jooq.impl.TableImpl) CatalogDefinition(org.jooq.meta.CatalogDefinition) UniqueKey(org.jooq.UniqueKey) Row(org.jooq.Row) IntStream.rangeClosed(java.util.stream.IntStream.rangeClosed) Time(java.sql.Time) Table(org.jooq.Table) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) DAOImpl(org.jooq.impl.DAOImpl) PackageDefinition(org.jooq.meta.PackageDefinition) DefaultDataType(org.jooq.impl.DefaultDataType) UDT(org.jooq.UDT) PostgresDatabase(org.jooq.meta.postgres.PostgresDatabase) SortOrder(org.jooq.SortOrder) DataType(org.jooq.DataType) DSL.name(org.jooq.impl.DSL.name) IdentityHashMap(java.util.IdentityHashMap) JooqLogger(org.jooq.tools.JooqLogger) SQLDialectNotSupportedException(org.jooq.exception.SQLDialectNotSupportedException) Collections.nCopies(java.util.Collections.nCopies) TimeZone(java.util.TimeZone) Name(org.jooq.Name) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) Check(org.jooq.Check) Field(org.jooq.Field) CloseResult(org.jooq.codegen.GeneratorWriter.CloseResult) PostgresRoutineDefinition(org.jooq.meta.postgres.PostgresRoutineDefinition) Collectors(java.util.stream.Collectors) UpdatableRecordImpl(org.jooq.impl.UpdatableRecordImpl) TypedElementDefinition(org.jooq.meta.TypedElementDefinition) JAVA(org.jooq.codegen.Language.JAVA) DomainDefinition(org.jooq.meta.DomainDefinition) Reflect(org.jooq.tools.reflect.Reflect) List(java.util.List) Modifier(java.lang.reflect.Modifier) Function.identity(java.util.function.Function.identity) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) IntStream(java.util.stream.IntStream) UniqueKeyDefinition(org.jooq.meta.UniqueKeyDefinition) KOTLIN(org.jooq.codegen.Language.KOTLIN) UDTField(org.jooq.UDTField) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) HashMap(java.util.HashMap) STORED(org.jooq.impl.QOM.GenerationOption.STORED) EnumType(org.jooq.EnumType) ForeignKey(org.jooq.ForeignKey) Function(java.util.function.Function) PackageImpl(org.jooq.impl.PackageImpl) Definition(org.jooq.meta.Definition) HashSet(java.util.HashSet) Identity(org.jooq.Identity) TableLike(org.jooq.TableLike) EmbeddableRecordImpl(org.jooq.impl.EmbeddableRecordImpl) EmbeddableDefinition(org.jooq.meta.EmbeddableDefinition) AbstractRoutine(org.jooq.impl.AbstractRoutine) Function2(org.jooq.Function2) ArrayDefinition(org.jooq.meta.ArrayDefinition) UDTDefinition(org.jooq.meta.UDTDefinition) AbstractTypedElementDefinition.getDataType(org.jooq.meta.AbstractTypedElementDefinition.getDataType) JavaTypeResolver(org.jooq.meta.JavaTypeResolver) ParameterDefinition(org.jooq.meta.ParameterDefinition) UDTRecordImpl(org.jooq.impl.UDTRecordImpl) ConstraintDefinition(org.jooq.meta.ConstraintDefinition) LazySchema(org.jooq.impl.LazySchema) DESC(org.jooq.SortOrder.DESC) SchemaImpl(org.jooq.impl.SchemaImpl) Date(java.sql.Date) ReflectException(org.jooq.tools.reflect.ReflectException) AbstractTypedElementDefinition(org.jooq.meta.AbstractTypedElementDefinition) Configuration(org.jooq.Configuration) Collectors.toList(java.util.stream.Collectors.toList) Catalog(org.jooq.Catalog) UDTImpl(org.jooq.impl.UDTImpl) StopWatch(org.jooq.tools.StopWatch) OrderField(org.jooq.OrderField) TableOptions(org.jooq.TableOptions) EnumDefinition(org.jooq.meta.EnumDefinition) ForeignKeyDefinition(org.jooq.meta.ForeignKeyDefinition) Collections(java.util.Collections) UniqueKeyDefinition(org.jooq.meta.UniqueKeyDefinition) Configuration(org.jooq.Configuration) AttributeDefinition(org.jooq.meta.AttributeDefinition) ColumnDefinition(org.jooq.meta.ColumnDefinition) RoutineDefinition(org.jooq.meta.RoutineDefinition) IndexColumnDefinition(org.jooq.meta.IndexColumnDefinition) IdentityDefinition(org.jooq.meta.IdentityDefinition) EmbeddableColumnDefinition(org.jooq.meta.EmbeddableColumnDefinition) CheckConstraintDefinition(org.jooq.meta.CheckConstraintDefinition) SequenceDefinition(org.jooq.meta.SequenceDefinition) TableDefinition(org.jooq.meta.TableDefinition) IndexDefinition(org.jooq.meta.IndexDefinition) SchemaDefinition(org.jooq.meta.SchemaDefinition) CatalogDefinition(org.jooq.meta.CatalogDefinition) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) PackageDefinition(org.jooq.meta.PackageDefinition) PostgresRoutineDefinition(org.jooq.meta.postgres.PostgresRoutineDefinition) TypedElementDefinition(org.jooq.meta.TypedElementDefinition) DomainDefinition(org.jooq.meta.DomainDefinition) UniqueKeyDefinition(org.jooq.meta.UniqueKeyDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) Definition(org.jooq.meta.Definition) EmbeddableDefinition(org.jooq.meta.EmbeddableDefinition) ArrayDefinition(org.jooq.meta.ArrayDefinition) UDTDefinition(org.jooq.meta.UDTDefinition) ParameterDefinition(org.jooq.meta.ParameterDefinition) ConstraintDefinition(org.jooq.meta.ConstraintDefinition) AbstractTypedElementDefinition(org.jooq.meta.AbstractTypedElementDefinition) EnumDefinition(org.jooq.meta.EnumDefinition) ForeignKeyDefinition(org.jooq.meta.ForeignKeyDefinition) EmbeddableDefinition(org.jooq.meta.EmbeddableDefinition) ColumnDefinition(org.jooq.meta.ColumnDefinition) IndexColumnDefinition(org.jooq.meta.IndexColumnDefinition) EmbeddableColumnDefinition(org.jooq.meta.EmbeddableColumnDefinition) Record(org.jooq.Record) Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList)

Example 2 with Definition

use of org.jooq.meta.Definition in project jOOQ by jOOQ.

the class JavaGenerator method generateTable.

protected void generateTable(TableDefinition table, JavaWriter out) {
    final SchemaDefinition schema = table.getSchema();
    final UniqueKeyDefinition primaryKey = table.getPrimaryKey();
    final String className = getStrategy().getJavaClassName(table);
    final String tableId = scala ? out.ref(getStrategy().getFullJavaIdentifier(table), 2) : getStrategy().getJavaIdentifier(table);
    final String recordType = out.ref(getStrategy().getFullJavaClassName(table, Mode.RECORD));
    final List<String> interfaces = out.ref(getStrategy().getJavaClassImplements(table, Mode.DEFAULT));
    final String schemaId = out.ref(getStrategy().getFullJavaIdentifier(schema), 2);
    final String tableType = table.isTemporary() ? "temporaryTable" : table.isView() ? "view" : table.isMaterializedView() ? "materializedView" : table.isTableValuedFunction() ? "function" : "table";
    final List<ParameterDefinition> parameters = table.getParameters();
    printPackage(out, table);
    if (scala) {
        out.println("object %s {", className);
        printSingletonInstance(out, table);
        out.println("}");
        out.println();
    }
    generateTableClassJavadoc(table, out);
    printClassAnnotations(out, table, Mode.DEFAULT);
    if (scala) {
        out.println("%sclass %s(", visibility(), className);
        out.println("alias: %s,", Name.class);
        out.println("child: %s[_ <: %s],", Table.class, Record.class);
        out.println("path: %s[_ <: %s, %s],", ForeignKey.class, Record.class, recordType);
        out.println("aliased: %s[%s],", Table.class, recordType);
        out.println("parameters: %s[ %s[_] ]", out.ref("scala.Array"), Field.class);
        out.println(")");
        out.println("extends %s[%s](", TableImpl.class, recordType);
        out.println("alias,");
        out.println("%s,", schemaId);
        out.println("child,");
        out.println("path,");
        out.println("aliased,");
        out.println("parameters,");
        out.println("%s.comment(\"%s\"),", DSL.class, escapeString(comment(table)));
        if ((generateSourcesOnViews() || table.isSynthetic()) && table.isView() && table.getSource() != null)
            out.println("%s.%s(\"%s\")", TableOptions.class, tableType, escapeString(table.getSource()));
        else if (table.isSynthetic() && table.isTableValuedFunction() && table.getSource() != null)
            out.println("%s.%s(\"%s\")", TableOptions.class, tableType, escapeString(table.getSource()));
        else
            out.println("%s.%s", TableOptions.class, tableType);
        out.println(")[[before= with ][separator= with ][%s]] {", interfaces);
    } else if (kotlin) {
        out.println("%sopen class %s(", visibility(), className);
        out.println("alias: %s,", Name.class);
        out.println("child: %s<out %s>?,", Table.class, Record.class);
        out.println("path: %s<out %s, %s>?,", ForeignKey.class, Record.class, recordType);
        out.println("aliased: %s<%s>?,", Table.class, recordType);
        out.println("parameters: Array<%s<*>?>?", Field.class);
        out.println("): %s<%s>(", TableImpl.class, recordType);
        out.println("alias,");
        out.println("%s,", schemaId);
        out.println("child,");
        out.println("path,");
        out.println("aliased,");
        out.println("parameters,");
        out.println("%s.comment(\"%s\"),", DSL.class, escapeString(comment(table)));
        if ((generateSourcesOnViews() || table.isSynthetic()) && table.isView() && table.getSource() != null)
            out.println("%s.%s(\"%s\")", TableOptions.class, tableType, escapeString(table.getSource()));
        else if (table.isSynthetic() && table.isTableValuedFunction() && table.getSource() != null)
            out.println("%s.%s(\"%s\")", TableOptions.class, tableType, escapeString(table.getSource()));
        else
            out.println("%s.%s()", TableOptions.class, tableType);
        out.println(")[[before=, ][%s]] {", interfaces);
        out.println("%scompanion object {", visibility());
        printSingletonInstance(out, table);
        out.println("}");
    } else {
        out.println("%sclass %s extends %s<%s>[[before= implements ][%s]] {", visibility(), className, TableImpl.class, recordType, interfaces);
        out.printSerial();
        printSingletonInstance(out, table);
    }
    printRecordTypeMethod(out, table);
    if (table.isSynthetic()) {
        if (scala) {
            out.println();
            out.println("protected override def isSynthetic(): Boolean = true");
        } else if (kotlin) {
            out.println();
            out.println("protected override fun isSynthetic(): Boolean = true");
        } else {
            out.println();
            out.override();
            out.println("protected boolean isSynthetic() {");
            out.println("return true;");
            out.println("}");
        }
    }
    for (ColumnDefinition column : table.getColumns()) {
        final String columnTypeFull = getJavaType(column.getType(resolver(out)), out);
        final String columnType = out.ref(columnTypeFull);
        final String columnTypeRef = getJavaTypeReference(column.getDatabase(), column.getType(resolver(out)), out);
        final String columnId = out.ref(getStrategy().getJavaIdentifier(column), colRefSegments(column));
        final String columnName = column.getName();
        final List<String> converter = out.ref(list(column.getType(resolver(out)).getConverter()));
        final List<String> binding = out.ref(list(column.getType(resolver(out)).getBinding()));
        final String columnVisibility = visibility();
        if (!printDeprecationIfUnknownType(out, columnTypeFull))
            out.javadoc("The column <code>%s</code>.[[before= ][%s]]", column.getQualifiedOutputName(), list(escapeEntities(comment(column))));
        if (scala) {
            out.println("%sval %s: %s[%s, %s] = createField(%s.name(\"%s\"), %s, \"%s\"" + converterTemplate(converter) + converterTemplate(binding) + ")", columnVisibility, scalaWhitespaceSuffix(columnId), TableField.class, recordType, columnType, DSL.class, columnName, columnTypeRef, escapeString(comment(column)), converter, binding);
        } else if (kotlin) {
            out.println("%sval %s: %s<%s, %s?> = createField(%s.name(\"%s\"), %s, this, \"%s\"" + converterTemplate(converter) + converterTemplate(binding) + ")", columnVisibility, columnId, TableField.class, recordType, columnType, DSL.class, columnName, columnTypeRef, escapeString(comment(column)), converter, binding);
        } else {
            String isStatic = generateInstanceFields() ? "" : "static ";
            String tableRef = generateInstanceFields() ? "this" : out.ref(getStrategy().getJavaIdentifier(table), 2);
            out.println("%s%sfinal %s<%s, %s> %s = createField(%s.name(\"%s\"), %s, %s, \"%s\"" + converterTemplate(converter) + converterTemplate(binding) + ");", columnVisibility, isStatic, TableField.class, recordType, columnType, columnId, DSL.class, columnName, columnTypeRef, tableRef, escapeString(comment(column)), converter, binding);
        }
    }
    // [#2530] Embeddable types
    for (EmbeddableDefinition embeddable : table.getReferencedEmbeddables()) {
        final String columnId = out.ref(getStrategy().getJavaIdentifier(embeddable), colRefSegments(null));
        final String columnType = out.ref(getStrategy().getFullJavaClassName(embeddable, Mode.RECORD));
        final List<String> columnIds = new ArrayList<>();
        for (EmbeddableColumnDefinition column : embeddable.getColumns()) columnIds.add(out.ref(getStrategy().getJavaIdentifier(column.getReferencingColumn()), colRefSegments(column.getReferencingColumn())));
        out.javadoc("The embeddable type <code>%s</code>.[[before= ][%s]]", embeddable.getOutputName(), list(escapeEntities(referencingComment(embeddable))));
        if (scala)
            out.println("%sval %s: %s[%s, %s] = %s.createEmbeddable(%s.name(\"%s\"), classOf[%s], %s, this, [[%s]])", visibility(), scalaWhitespaceSuffix(columnId), TableField.class, recordType, columnType, Internal.class, DSL.class, escapeString(embeddable.getName()), columnType, embeddable.replacesFields(), columnIds);
        else if (kotlin)
            out.println("%sval %s: %s<%s, %s> = %s.createEmbeddable(%s.name(\"%s\"), %s::class.java, %s, this, [[%s]])", visibility(), columnId, TableField.class, recordType, columnType, Internal.class, DSL.class, escapeString(embeddable.getName()), columnType, embeddable.replacesFields(), columnIds);
        else
            out.println("%sfinal %s<%s, %s> %s = %s.createEmbeddable(%s.name(\"%s\"), %s.class, %s, this, [[%s]]);", visibility(), TableField.class, recordType, columnType, columnId, Internal.class, DSL.class, escapeString(embeddable.getName()), columnType, embeddable.replacesFields(), columnIds);
    }
    out.println();
    // "called constructor's definition must precede calling constructor's definition"
    if (scala) {
        if (table.isTableValuedFunction()) {
            out.println("private def this(alias: %s, aliased: %s[%s]) = this(alias, null, null, aliased, %s(", Name.class, Table.class, recordType, out.ref("scala.Array"));
            forEach(parameters, (parameter, separator) -> {
                final String paramTypeRef = getJavaTypeReference(parameter.getDatabase(), parameter.getType(resolver(out)), out);
                final List<String> converter = out.ref(list(parameter.getType(resolver(out)).getConverter()));
                final List<String> binding = out.ref(list(parameter.getType(resolver(out)).getBinding()));
                out.println("%s.value(null, %s" + converterTemplateForTableValuedFunction(converter) + converterTemplateForTableValuedFunction(binding) + ")%s", DSL.class, paramTypeRef, converter, binding, separator);
            });
            out.println("))");
        } else
            out.println("private def this(alias: %s, aliased: %s[%s]) = this(alias, null, null, aliased, null)", Name.class, Table.class, recordType);
    } else if (kotlin) {
        if (table.isTableValuedFunction()) {
            out.println("private constructor(alias: %s, aliased: %s<%s>?): this(alias, null, null, aliased, arrayOf(", Name.class, Table.class, recordType, Field.class, parameters.size());
            forEach(parameters, (parameter, separator) -> {
                final String paramTypeRef = getJavaTypeReference(parameter.getDatabase(), parameter.getType(resolver(out)), out);
                final List<String> converter = out.ref(list(parameter.getType(resolver(out)).getConverter()));
                final List<String> binding = out.ref(list(parameter.getType(resolver(out)).getBinding()));
                out.println("%s.value(null, %s" + converterTemplateForTableValuedFunction(converter) + converterTemplateForTableValuedFunction(binding) + ")%s", DSL.class, paramTypeRef, converter, binding, separator);
            });
            out.println("))");
        } else
            out.println("private constructor(alias: %s, aliased: %s<%s>?): this(alias, null, null, aliased, null)", Name.class, Table.class, recordType);
        out.println("private constructor(alias: %s, aliased: %s<%s>?, parameters: Array<%s<*>?>?): this(alias, null, null, aliased, parameters)", Name.class, Table.class, recordType, Field.class);
    } else {
        out.println("private %s(%s alias, %s<%s> aliased) {", className, Name.class, Table.class, recordType);
        if (table.isTableValuedFunction()) {
            out.println("this(alias, aliased, new %s[] {", Field.class);
            forEach(parameters, (parameter, separator) -> {
                final String paramTypeRef = getJavaTypeReference(parameter.getDatabase(), parameter.getType(resolver(out)), out);
                final List<String> converter = out.ref(list(parameter.getType(resolver(out)).getConverter()));
                final List<String> binding = out.ref(list(parameter.getType(resolver(out)).getBinding()));
                out.println("%s.val(null, %s" + converterTemplateForTableValuedFunction(converter) + converterTemplateForTableValuedFunction(binding) + ")%s", DSL.class, paramTypeRef, converter, binding, separator);
            });
            out.println("});");
        } else
            out.println("this(alias, aliased, null);");
        out.println("}");
        out.println();
        out.println("private %s(%s alias, %s<%s> aliased, %s<?>[] parameters) {", className, Name.class, Table.class, recordType, Field.class);
        if ((generateSourcesOnViews() || table.isSynthetic()) && table.isView() && table.getSource() != null)
            out.println("super(alias, null, aliased, parameters, %s.comment(\"%s\"), %s.%s(\"%s\"));", DSL.class, escapeString(comment(table)), TableOptions.class, tableType, escapeString(table.getSource()));
        else if (table.isSynthetic() && table.isTableValuedFunction() && table.getSource() != null)
            out.println("super(alias, null, aliased, parameters, %s.comment(\"%s\"), %s.%s(\"%s\"));", DSL.class, escapeString(comment(table)), TableOptions.class, tableType, escapeString(table.getSource()));
        else
            out.println("super(alias, null, aliased, parameters, %s.comment(\"%s\"), %s.%s());", DSL.class, escapeString(comment(table)), TableOptions.class, tableType);
        out.println("}");
    }
    if (scala) {
        out.javadoc("Create an aliased <code>%s</code> table reference", table.getQualifiedOutputName());
        out.println("%sdef this(alias: %s) = this(%s.name(alias), %s)", visibility(), String.class, DSL.class, tableId);
        out.javadoc("Create an aliased <code>%s</code> table reference", table.getQualifiedOutputName());
        out.println("%sdef this(alias: %s) = this(alias, %s)", visibility(), Name.class, tableId);
    } else if (kotlin) {
        out.javadoc("Create an aliased <code>%s</code> table reference", table.getQualifiedOutputName());
        out.println("%sconstructor(alias: %s): this(%s.name(alias))", visibility(), String.class, DSL.class);
        out.javadoc("Create an aliased <code>%s</code> table reference", table.getQualifiedOutputName());
        out.println("%sconstructor(alias: %s): this(alias, null)", visibility(), Name.class, tableId);
    } else // be public, as tables are no longer singletons
    if (generateInstanceFields()) {
        out.javadoc("Create an aliased <code>%s</code> table reference", table.getQualifiedOutputName());
        out.println("%s%s(%s alias) {", visibility(), className, String.class);
        out.println("this(%s.name(alias), %s);", DSL.class, tableId);
        out.println("}");
        out.javadoc("Create an aliased <code>%s</code> table reference", table.getQualifiedOutputName());
        out.println("%s%s(%s alias) {", visibility(), className, Name.class);
        out.println("this(alias, %s);", tableId);
        out.println("}");
    }
    if (scala) {
        out.javadoc("Create a <code>%s</code> table reference", table.getQualifiedOutputName());
        out.println("%sdef this() = this(%s.name(\"%s\"), null)", visibility(), DSL.class, escapeString(table.getOutputName()));
    } else if (kotlin) {
        out.javadoc("Create a <code>%s</code> table reference", table.getQualifiedOutputName());
        out.println("%sconstructor(): this(%s.name(\"%s\"), null)", visibility(), DSL.class, escapeString(table.getOutputName()));
    } else {
        // be public, as tables are no longer singletons
        if (generateInstanceFields()) {
            out.javadoc("Create a <code>%s</code> table reference", table.getQualifiedOutputName());
            out.println("%s%s() {", visibility(), className);
        } else {
            out.javadoc(NO_FURTHER_INSTANCES_ALLOWED);
            out.println("private %s() {", className);
        }
        out.println("this(%s.name(\"%s\"), null);", DSL.class, escapeString(table.getOutputName()));
        out.println("}");
    }
    if (generateImplicitJoinPathsToOne() && generateGlobalKeyReferences() && !table.isTableValuedFunction()) {
        out.println();
        if (scala) {
            out.println("%sdef this(child: %s[_ <: %s], key: %s[_ <: %s, %s]) = this(%s.createPathAlias(child, key), child, key, %s, null)", visibility(), Table.class, Record.class, ForeignKey.class, Record.class, recordType, Internal.class, tableId);
        } else if (kotlin) {
            out.println("%sconstructor(child: %s<out %s>, key: %s<out %s, %s>): this(%s.createPathAlias(child, key), child, key, %s, null)", visibility(), Table.class, Record.class, ForeignKey.class, Record.class, recordType, Internal.class, tableId);
        } else {
            out.println("%s<O extends %s> %s(%s<O> child, %s<O, %s> key) {", visibility(), Record.class, className, Table.class, ForeignKey.class, recordType);
            out.println("super(child, key, %s);", tableId);
            out.println("}");
        }
    }
    if (scala) {
        out.println();
        out.println("%soverride def getSchema: %s = if (aliased()) null else %s", visibilityPublic(), Schema.class, schemaId);
    } else if (kotlin) {
        out.println("%soverride fun getSchema(): %s? = if (aliased()) null else %s", visibilityPublic(), Schema.class, schemaId);
    } else {
        out.overrideInherit();
        printNonnullAnnotation(out);
        out.println("%s%s getSchema() {", visibilityPublic(), Schema.class);
        out.println("return aliased() ? null : %s;", schemaId);
        out.println("}");
    }
    // Add index information
    if (generateIndexes()) {
        List<IndexDefinition> indexes = table.getIndexes();
        if (!indexes.isEmpty()) {
            if (generateGlobalIndexReferences()) {
                final List<String> indexFullIds = kotlin ? out.ref(getStrategy().getFullJavaIdentifiers(indexes)) : out.ref(getStrategy().getFullJavaIdentifiers(indexes), 2);
                if (scala) {
                    out.println();
                    out.println("%soverride def getIndexes: %s[%s] = %s.asList[ %s ]([[%s]])", visibilityPublic(), List.class, Index.class, Arrays.class, Index.class, indexFullIds);
                } else if (kotlin) {
                    out.println("%soverride fun getIndexes(): %s<%s> = listOf([[%s]])", visibilityPublic(), out.ref(KLIST), Index.class, indexFullIds);
                } else {
                    out.overrideInherit();
                    printNonnullAnnotation(out);
                    out.println("%s%s<%s> getIndexes() {", visibilityPublic(), List.class, Index.class);
                    out.println("return %s.asList([[%s]]);", Arrays.class, indexFullIds);
                    out.println("}");
                }
            } else {
                if (scala) {
                    out.println();
                    out.println("%soverride def getIndexes: %s[%s] = %s.asList[%s](", visibilityPublic(), List.class, Index.class, Arrays.class, Index.class);
                    forEach(indexes, "", ", ", (index, separator) -> {
                        printCreateIndex(out, index);
                        out.println("%s", separator);
                    });
                    out.println(")");
                } else if (kotlin) {
                    out.println("%soverride fun getIndexes(): %s<%s> = listOf(", visibilityPublic(), out.ref(KLIST), Index.class);
                    forEach(indexes, "", ", ", (index, separator) -> {
                        printCreateIndex(out, index);
                        out.println("%s", separator);
                    });
                    out.println(")");
                } else {
                    out.overrideInherit();
                    printNonnullAnnotation(out);
                    out.println("%s%s<%s> getIndexes() {", visibilityPublic(), List.class, Index.class);
                    out.println("return %s.asList(", Arrays.class);
                    forEach(indexes, "", ", ", (index, separator) -> {
                        printCreateIndex(out, index);
                        out.println("%s", separator);
                    });
                    out.println(");");
                    out.println("}");
                }
            }
        }
    }
    // Add primary / unique / foreign key information
    if (generateRelations()) {
        IdentityDefinition identity = table.getIdentity();
        // The identity column
        if (identity != null) {
            final String identityTypeFull = getJavaType(identity.getColumn().getType(resolver(out)), out);
            final String identityType = out.ref(identityTypeFull);
            if (scala) {
                out.println();
                printDeprecationIfUnknownType(out, identityTypeFull);
                out.println("%soverride def getIdentity: %s[%s, %s] = super.getIdentity.asInstanceOf[ %s[%s, %s] ]", visibilityPublic(), Identity.class, recordType, identityType, Identity.class, recordType, identityType);
            } else if (kotlin) {
                printDeprecationIfUnknownType(out, identityTypeFull);
                out.println("%soverride fun getIdentity(): %s<%s, %s?> = super.getIdentity() as %s<%s, %s?>", visibilityPublic(), Identity.class, recordType, identityType, Identity.class, recordType, identityType);
            } else {
                if (printDeprecationIfUnknownType(out, identityTypeFull))
                    out.override();
                else
                    out.overrideInherit();
                printNonnullAnnotation(out);
                out.println("%s%s<%s, %s> getIdentity() {", visibilityPublic(), Identity.class, recordType, identityType);
                out.println("return (%s<%s, %s>) super.getIdentity();", Identity.class, recordType, identityType);
                out.println("}");
            }
        }
        // The primary / main unique key
        if (primaryKey != null) {
            final String keyFullId = generateGlobalKeyReferences() ? kotlin ? out.ref(getStrategy().getFullJavaIdentifier(primaryKey)) : out.ref(getStrategy().getFullJavaIdentifier(primaryKey), 2) : null;
            if (scala) {
                out.println();
                out.print("%soverride def getPrimaryKey: %s[%s] = ", visibilityPublic(), UniqueKey.class, recordType);
                if (keyFullId != null)
                    out.print("%s", keyFullId);
                else
                    printCreateUniqueKey(out, primaryKey);
                out.println();
            } else if (kotlin) {
                out.print("%soverride fun getPrimaryKey(): %s<%s> = ", visibilityPublic(), UniqueKey.class, recordType);
                if (keyFullId != null)
                    out.print("%s", keyFullId);
                else
                    printCreateUniqueKey(out, primaryKey);
                out.println();
            } else {
                out.overrideInherit();
                printNonnullAnnotation(out);
                out.println("%s%s<%s> getPrimaryKey() {", visibilityPublic(), UniqueKey.class, recordType);
                out.print("return ");
                if (keyFullId != null)
                    out.print("%s", keyFullId);
                else
                    printCreateUniqueKey(out, primaryKey);
                out.println(";");
                out.println("}");
            }
        }
        // The remaining unique keys
        List<UniqueKeyDefinition> uniqueKeys = table.getUniqueKeys();
        if (uniqueKeys.size() > 0) {
            if (generateGlobalKeyReferences()) {
                final List<String> keyFullIds = kotlin ? out.ref(getStrategy().getFullJavaIdentifiers(uniqueKeys)) : out.ref(getStrategy().getFullJavaIdentifiers(uniqueKeys), 2);
                if (scala) {
                    out.println();
                    out.println("%soverride def getUniqueKeys: %s[ %s[%s] ] = %s.asList[ %s[%s] ]([[%s]])", visibilityPublic(), List.class, UniqueKey.class, recordType, Arrays.class, UniqueKey.class, recordType, keyFullIds);
                } else if (kotlin) {
                    out.println("%soverride fun getUniqueKeys(): %s<%s<%s>> = listOf([[%s]])", visibilityPublic(), out.ref(KLIST), UniqueKey.class, recordType, keyFullIds);
                } else {
                    out.overrideInherit();
                    printNonnullAnnotation(out);
                    out.println("%s%s<%s<%s>> getUniqueKeys() {", visibilityPublic(), List.class, UniqueKey.class, recordType);
                    out.println("return %s.asList([[%s]]);", Arrays.class, keyFullIds);
                    out.println("}");
                }
            } else {
                if (scala) {
                    out.println();
                    out.println("%soverride def getUniqueKeys: %s[ %s[%s] ] = %s.asList[ %s[%s] ](", visibilityPublic(), List.class, UniqueKey.class, recordType, Arrays.class, UniqueKey.class, recordType);
                    forEach(uniqueKeys, "", ", ", (uniqueKey, separator) -> {
                        printCreateUniqueKey(out, uniqueKey);
                        out.println("%s", separator);
                    });
                    out.println(")");
                } else if (kotlin) {
                    out.println("%soverride fun getUniqueKeys(): %s<%s<%s>> = listOf(", visibilityPublic(), out.ref(KLIST), UniqueKey.class, recordType);
                    forEach(uniqueKeys, "", ", ", (uniqueKey, separator) -> {
                        printCreateUniqueKey(out, uniqueKey);
                        out.println("%s", separator);
                    });
                    out.println(")");
                } else {
                    out.overrideInherit();
                    printNonnullAnnotation(out);
                    out.println("%s%s<%s<%s>> getUniqueKeys() {", visibilityPublic(), List.class, UniqueKey.class, recordType);
                    out.println("return %s.asList(", Arrays.class);
                    forEach(uniqueKeys, "", ", ", (uniqueKey, separator) -> {
                        printCreateUniqueKey(out, uniqueKey);
                        out.println("%s", separator);
                    });
                    out.println(");");
                    out.println("}");
                }
            }
        }
        // Foreign keys
        List<ForeignKeyDefinition> foreignKeys = table.getForeignKeys();
        // [#7554] [#8028] Not yet supported with global key references turned off
        if (foreignKeys.size() > 0 && generateGlobalKeyReferences()) {
            final List<String> keyFullIds = kotlin ? out.ref(getStrategy().getFullJavaIdentifiers(foreignKeys)) : out.ref(getStrategy().getFullJavaIdentifiers(foreignKeys), 2);
            if (scala) {
                out.println();
                out.println("%soverride def getReferences: %s[ %s[%s, _] ] = %s.asList[ %s[%s, _] ]([[%s]])", visibilityPublic(), List.class, ForeignKey.class, recordType, Arrays.class, ForeignKey.class, recordType, keyFullIds);
            } else if (kotlin) {
                out.println("%soverride fun getReferences(): %s<%s<%s, *>> = listOf([[%s]])", visibilityPublic(), out.ref(KLIST), ForeignKey.class, recordType, keyFullIds);
            } else {
                out.overrideInherit();
                printNonnullAnnotation(out);
                out.println("%s%s<%s<%s, ?>> getReferences() {", visibilityPublic(), List.class, ForeignKey.class, recordType);
                out.println("return %s.asList([[%s]]);", Arrays.class, keyFullIds);
                out.println("}");
            }
            // Outbound (to-one) implicit join paths
            if (generateImplicitJoinPathsToOne()) {
                if (scala) {
                } else {
                    out.println();
                    // [#8762] Cache these calls for much improved runtime performance!
                    for (ForeignKeyDefinition foreignKey : foreignKeys) {
                        final String referencedTableClassName = out.ref(getStrategy().getFullJavaClassName(foreignKey.getReferencedTable()));
                        final String keyMethodName = out.ref(getStrategy().getJavaMethodName(foreignKey));
                        // [#13008] Prevent conflicts with the below leading underscore
                        final String unquotedKeyMethodName = keyMethodName.replace("`", "");
                        if (kotlin)
                            out.println("private lateinit var _%s: %s", unquotedKeyMethodName, referencedTableClassName);
                        else
                            out.println("private transient %s _%s;", referencedTableClassName, keyMethodName);
                    }
                }
                Map<TableDefinition, Long> pathCounts = foreignKeys.stream().collect(groupingBy(ForeignKeyDefinition::getReferencedTable, counting()));
                for (ForeignKeyDefinition foreignKey : foreignKeys) {
                    final String keyFullId = kotlin ? out.ref(getStrategy().getFullJavaIdentifier(foreignKey)) : out.ref(getStrategy().getFullJavaIdentifier(foreignKey), 2);
                    final String referencedTableClassName = out.ref(getStrategy().getFullJavaClassName(foreignKey.getReferencedTable()));
                    final String keyMethodName = out.ref(getStrategy().getJavaMethodName(foreignKey));
                    final String unquotedKeyMethodName = keyMethodName.replace("`", "");
                    out.javadoc("Get the implicit join path to the <code>" + foreignKey.getReferencedTable().getQualifiedName() + "</code> table" + (pathCounts.get(foreignKey.getReferencedTable()) > 1 ? ", via the <code>" + foreignKey.getInputName() + "</code> key" : "") + ".");
                    if (scala) {
                        out.println("%slazy val %s: %s = { new %s(this, %s) }", visibility(), scalaWhitespaceSuffix(keyMethodName), referencedTableClassName, referencedTableClassName, keyFullId);
                    } else if (kotlin) {
                        out.println("%sfun %s(): %s {", visibility(), keyMethodName, referencedTableClassName);
                        out.println("if (!this::_%s.isInitialized)", unquotedKeyMethodName);
                        out.println("_%s = %s(this, %s)", unquotedKeyMethodName, referencedTableClassName, keyFullId);
                        out.println();
                        out.println("return _%s;", unquotedKeyMethodName);
                        out.println("}");
                    } else {
                        out.println("%s%s %s() {", visibility(), referencedTableClassName, keyMethodName);
                        out.println("if (_%s == null)", keyMethodName);
                        out.println("_%s = new %s(this, %s);", keyMethodName, referencedTableClassName, keyFullId);
                        out.println();
                        out.println("return _%s;", keyMethodName);
                        out.println("}");
                    }
                }
            }
        }
    }
    List<CheckConstraintDefinition> cc = table.getCheckConstraints();
    if (!cc.isEmpty()) {
        if (scala) {
            out.println("%soverride def getChecks: %s[ %s[%s] ] = %s.asList[ %s[%s] ](", visibilityPublic(), List.class, Check.class, recordType, Arrays.class, Check.class, recordType);
        } else if (kotlin) {
            out.println("%soverride fun getChecks(): %s<%s<%s>> = listOf(", visibilityPublic(), out.ref(KLIST), Check.class, recordType);
        } else {
            out.overrideInherit();
            printNonnullAnnotation(out);
            out.println("%s%s<%s<%s>> getChecks() {", visibilityPublic(), List.class, Check.class, recordType);
            out.println("return %s.asList(", Arrays.class);
        }
        forEach(cc, (c, separator) -> {
            out.println("%s.createCheck(this, %s.name(\"%s\"), \"%s\", %s)%s", Internal.class, DSL.class, escapeString(c.getName()), escapeString(c.getCheckClause()), c.enforced(), separator);
        });
        if (scala || kotlin) {
            out.println(")");
        } else {
            out.println(");");
            out.println("}");
        }
    }
    // can still be generated
    versionLoop: for (String pattern : database.getRecordVersionFields()) {
        Pattern p = Pattern.compile(pattern, Pattern.COMMENTS);
        for (ColumnDefinition column : table.getColumns()) {
            if ((p.matcher(column.getName()).matches() || p.matcher(column.getQualifiedName()).matches())) {
                final String columnTypeFull = getJavaType(column.getType(resolver(out)), out);
                final String columnType = out.ref(columnTypeFull);
                final String columnId = getStrategy().getJavaIdentifier(column);
                if (scala) {
                    printDeprecationIfUnknownType(out, columnTypeFull);
                    out.println("%soverride def getRecordVersion: %s[%s, %s] = %s", visibilityPublic(), TableField.class, recordType, columnType, columnId);
                } else if (kotlin) {
                    printDeprecationIfUnknownType(out, columnTypeFull);
                    out.println("%soverride fun getRecordVersion(): %s<%s, %s?> = %s", visibilityPublic(), TableField.class, recordType, columnType, columnId);
                } else {
                    if (printDeprecationIfUnknownType(out, columnTypeFull))
                        out.override();
                    else
                        out.overrideInherit();
                    printNonnullAnnotation(out);
                    out.println("%s%s<%s, %s> getRecordVersion() {", visibilityPublic(), TableField.class, recordType, columnType);
                    out.println("return %s;", columnId);
                    out.println("}");
                }
                // Avoid generating this method twice
                break versionLoop;
            }
        }
    }
    timestampLoop: for (String pattern : database.getRecordTimestampFields()) {
        Pattern p = Pattern.compile(pattern, Pattern.COMMENTS);
        for (ColumnDefinition column : table.getColumns()) {
            if ((p.matcher(column.getName()).matches() || p.matcher(column.getQualifiedName()).matches())) {
                final String columnTypeFull = getJavaType(column.getType(resolver(out)), out);
                final String columnType = out.ref(columnTypeFull);
                final String columnId = getStrategy().getJavaIdentifier(column);
                if (scala) {
                    printDeprecationIfUnknownType(out, columnTypeFull);
                    out.println("%soverride def getRecordTimestamp: %s[%s, %s] = %s", visibilityPublic(), TableField.class, recordType, columnType, columnId);
                } else if (kotlin) {
                    printDeprecationIfUnknownType(out, columnTypeFull);
                    out.println("%soverride fun getRecordTimestamp(): %s<%s, %s?> = %s", visibilityPublic(), TableField.class, recordType, columnType, columnId);
                } else {
                    if (printDeprecationIfUnknownType(out, columnTypeFull))
                        out.override();
                    else
                        out.overrideInherit();
                    printNonnullAnnotation(out);
                    out.println("%s%s<%s, %s> getRecordTimestamp() {", visibilityPublic(), TableField.class, recordType, columnType);
                    out.println("return %s;", columnId);
                    out.println("}");
                }
                // Avoid generating this method twice
                break timestampLoop;
            }
        }
    }
    if (scala) {
        out.print("%soverride def as(alias: %s): %s = ", visibilityPublic(), String.class, className);
        if (table.isTableValuedFunction())
            out.println("new %s(%s.name(alias), null, null, this, parameters)", className, DSL.class);
        else
            out.println("new %s(%s.name(alias), this)", className, DSL.class);
        out.print("%soverride def as(alias: %s): %s = ", visibilityPublic(), Name.class, className);
        if (table.isTableValuedFunction())
            out.println("new %s(alias, null, null, this, parameters)", className);
        else
            out.println("new %s(alias, this)", className);
    } else if (kotlin) {
        out.print("%soverride fun `as`(alias: %s): %s = ", visibilityPublic(), String.class, className);
        if (table.isTableValuedFunction())
            out.println("%s(%s.name(alias), this, parameters)", className, DSL.class);
        else
            out.println("%s(%s.name(alias), this)", className, DSL.class);
        out.print("%soverride fun `as`(alias: %s): %s = ", visibilityPublic(), Name.class, className);
        if (table.isTableValuedFunction())
            out.println("%s(alias, this, parameters)", className);
        else
            out.println("%s(alias, this)", className);
    } else // type-safe table alias
    if (generateInstanceFields()) {
        out.overrideInherit();
        printNonnullAnnotation(out);
        out.println("%s%s as(%s alias) {", visibilityPublic(), className, String.class);
        if (table.isTableValuedFunction())
            out.println("return new %s(%s.name(alias), this, parameters);", className, DSL.class);
        else
            out.println("return new %s(%s.name(alias), this);", className, DSL.class);
        out.println("}");
        out.overrideInherit();
        printNonnullAnnotation(out);
        out.println("%s%s as(%s alias) {", visibilityPublic(), className, Name.class);
        if (table.isTableValuedFunction())
            out.println("return new %s(alias, this, parameters);", className);
        else
            out.println("return new %s(alias, this);", className);
        out.println("}");
    }
    if (scala) {
        out.javadoc("Rename this table");
        out.print("%soverride def rename(name: %s): %s = ", visibilityPublic(), String.class, className);
        if (table.isTableValuedFunction())
            out.println("new %s(%s.name(name), null, null, null, parameters)", className, DSL.class);
        else
            out.println("new %s(%s.name(name), null)", className, DSL.class);
        out.javadoc("Rename this table");
        out.print("%soverride def rename(name: %s): %s = ", visibilityPublic(), Name.class, className);
        if (table.isTableValuedFunction())
            out.println("new %s(name, null, null, null, parameters)", className);
        else
            out.println("new %s(name, null)", className);
    } else if (kotlin) {
        out.javadoc("Rename this table");
        out.print("%soverride fun rename(name: %s): %s = ", visibilityPublic(), String.class, className);
        if (table.isTableValuedFunction())
            out.println("%s(%s.name(name), null, parameters)", className, DSL.class);
        else
            out.println("%s(%s.name(name), null)", className, DSL.class);
        out.javadoc("Rename this table");
        out.print("%soverride fun rename(name: %s): %s = ", visibilityPublic(), Name.class, className);
        if (table.isTableValuedFunction())
            out.println("%s(name, null, parameters)", className);
        else
            out.println("%s(name, null)", className);
    } else // [#2921] With instance fields, tables can be renamed.
    if (generateInstanceFields()) {
        out.javadoc("Rename this table");
        out.override();
        printNonnullAnnotation(out);
        out.println("%s%s rename(%s name) {", visibilityPublic(), className, String.class);
        if (table.isTableValuedFunction())
            out.println("return new %s(%s.name(name), null, parameters);", className, DSL.class);
        else
            out.println("return new %s(%s.name(name), null);", className, DSL.class);
        out.println("}");
        out.javadoc("Rename this table");
        out.override();
        printNonnullAnnotation(out);
        out.println("%s%s rename(%s name) {", visibilityPublic(), className, Name.class);
        if (table.isTableValuedFunction())
            out.println("return new %s(name, null, parameters);", className);
        else
            out.println("return new %s(name, null);", className);
        out.println("}");
    }
    // [#7809] fieldsRow()
    // [#10481] Use the types from replaced embeddables if applicable
    List<Definition> replacingEmbeddablesAndUnreplacedColumns = replacingEmbeddablesAndUnreplacedColumns(table);
    int degree = replacingEmbeddablesAndUnreplacedColumns.size();
    String rowType = refRowType(out, replacingEmbeddablesAndUnreplacedColumns);
    String rowTypeContravariantJava = refRowType(out, replacingEmbeddablesAndUnreplacedColumns, s -> "? super " + s);
    if (generateRecordsImplementingRecordN() && degree > 0 && degree <= Constants.MAX_ROW_DEGREE) {
        final String rowNType = out.ref(Row.class.getName() + degree);
        out.header("Row%s type methods", degree);
        if (scala) {
            out.println("%soverride def fieldsRow: %s[%s] = super.fieldsRow.asInstanceOf[ %s[%s] ]", visibilityPublic(), rowNType, rowType, rowNType, rowType);
        } else if (kotlin) {
            out.println("%soverride fun fieldsRow(): %s<%s> = super.fieldsRow() as %s<%s>", visibilityPublic(), rowNType, rowType, rowNType, rowType);
        } else {
            out.overrideInherit();
            printNonnullAnnotation(out);
            out.println("%s%s<%s> fieldsRow() {", visibilityPublic(), rowNType, rowType);
            out.println("return (%s) super.fieldsRow();", rowNType);
            out.println("}");
        }
    }
    // [#1070] Table-valued functions should generate an additional set of call() methods
    if (table.isTableValuedFunction()) {
        for (boolean parametersAsField : new boolean[] { false, true }) {
            // Don't overload no-args call() methods
            if (parametersAsField && parameters.size() == 0)
                break;
            out.javadoc("Call this table-valued function");
            if (scala) {
                out.print("%sdef call(", visibility()).printlnIf(!parameters.isEmpty());
                printParameterDeclarations(out, parameters, parametersAsField, "  ");
                out.print("): %s = ", className);
                out.print("Option(new %s(%s.name(\"%s\"), null, null, null, %s(", className, DSL.class, escapeString(table.getOutputName()), out.ref("scala.Array")).printlnIf(!parameters.isEmpty());
                forEach(parameters, (parameter, separator) -> {
                    final String paramArgName = getStrategy().getJavaMemberName(parameter);
                    final String paramTypeRef = getJavaTypeReference(parameter.getDatabase(), parameter.getType(resolver(out)), out);
                    final List<String> converter = out.ref(list(parameter.getType(resolver(out)).getConverter()));
                    final List<String> binding = out.ref(list(parameter.getType(resolver(out)).getBinding()));
                    if (parametersAsField)
                        out.println("%s%s", paramArgName, separator);
                    else
                        out.println("%s.value(%s, %s" + converterTemplateForTableValuedFunction(converter) + converterTemplateForTableValuedFunction(binding) + ")%s", DSL.class, paramArgName, paramTypeRef, converter, binding, separator);
                });
                out.println("))).map(r => if (aliased()) r.as(getUnqualifiedName) else r).get");
            } else if (kotlin) {
                out.print("%sfun call(", visibility()).printlnIf(!parameters.isEmpty());
                printParameterDeclarations(out, parameters, parametersAsField, "  ");
                out.print("): %s = %s(%s.name(\"%s\"), null, arrayOf(", className, className, DSL.class, escapeString(table.getOutputName()), Field.class).printlnIf(!parameters.isEmpty());
                forEach(parameters, (parameter, separator) -> {
                    final String paramArgName = getStrategy().getJavaMemberName(parameter);
                    final String paramTypeRef = getJavaTypeReference(parameter.getDatabase(), parameter.getType(resolver(out)), out);
                    final List<String> converter = out.ref(list(parameter.getType(resolver(out)).getConverter()));
                    final List<String> binding = out.ref(list(parameter.getType(resolver(out)).getBinding()));
                    if (parametersAsField)
                        out.println("%s%s", paramArgName, separator);
                    else
                        out.println("%s.value(%s, %s" + converterTemplateForTableValuedFunction(converter) + converterTemplateForTableValuedFunction(binding) + ")%s", DSL.class, paramArgName, paramTypeRef, converter, binding, separator);
                });
                out.println(")).let { if (aliased()) it.`as`(unqualifiedName) else it }");
            } else {
                out.print("%s%s call(", visibility(), className).printlnIf(!parameters.isEmpty());
                printParameterDeclarations(out, parameters, parametersAsField, "  ");
                out.println(") {");
                out.print("%s result = new %s(%s.name(\"%s\"), null, new %s[] {", className, className, DSL.class, escapeString(table.getOutputName()), Field.class).printlnIf(!parameters.isEmpty());
                forEach(parameters, (parameter, separator) -> {
                    final String paramArgName = getStrategy().getJavaMemberName(parameter);
                    final String paramTypeRef = getJavaTypeReference(parameter.getDatabase(), parameter.getType(resolver(out)), out);
                    final List<String> converter = out.ref(list(parameter.getType(resolver(out)).getConverter()));
                    final List<String> binding = out.ref(list(parameter.getType(resolver(out)).getBinding()));
                    if (parametersAsField)
                        out.println("%s%s", paramArgName, separator);
                    else
                        out.println("%s.val(%s, %s" + converterTemplateForTableValuedFunction(converter) + converterTemplateForTableValuedFunction(binding) + ")%s", DSL.class, paramArgName, paramTypeRef, converter, binding, separator);
                });
                out.println("});");
                out.println();
                out.println("return aliased() ? result.as(getUnqualifiedName()) : result;");
                out.println("}");
            }
        }
    }
    if (generateRecordsImplementingRecordN() && degree > 0 && degree <= Constants.MAX_ROW_DEGREE) {
        out.javadoc("Convenience mapping calling {@link #convertFrom(%s)}.", Function.class);
        if (scala) {
            out.println("%sdef mapping[U](from: (" + rowType + ") => U): %s[U] = convertFrom(r => from.apply(" + rangeClosed(1, degree).mapToObj(i -> "r.value" + i + "()").collect(joining(", ")) + "))", visibility(), SelectField.class);
        } else if (kotlin) {
            out.println("%sfun <U> mapping(from: (" + rowType + ") -> U): %s<U> = convertFrom(%s.mapping(from))", visibility(), SelectField.class, Records.class);
        } else {
            out.println("%s<U> %s<U> mapping(%s<" + rowTypeContravariantJava + ", ? extends U> from) {", visibility(), SelectField.class, out.ref("org.jooq.Function" + degree));
            out.println("return convertFrom(%s.mapping(from));", Records.class);
            out.println("}");
        }
        out.javadoc("Convenience mapping calling {@link #convertFrom(%s, %s)}.", Class.class, Function.class);
        if (scala) {
            out.println("%sdef mapping[U](toType: %s[U], from: (" + rowType + ") => U): %s[U] = convertFrom(toType,r => from.apply(" + rangeClosed(1, degree).mapToObj(i -> "r.value" + i + "()").collect(joining(", ")) + "))", visibility(), Class.class, SelectField.class);
        } else if (kotlin) {
            out.println("%sfun <U> mapping(toType: %s<U>, from: (" + rowType + ") -> U): %s<U> = convertFrom(toType, %s.mapping(from))", visibility(), Class.class, SelectField.class, Records.class);
        } else {
            out.println("%s<U> %s<U> mapping(%s<U> toType, %s<" + rowTypeContravariantJava + ", ? extends U> from) {", visibility(), SelectField.class, Class.class, out.ref("org.jooq.Function" + degree));
            out.println("return convertFrom(toType, %s.mapping(from));", Records.class);
            out.println("}");
        }
    }
    generateTableClassFooter(table, out);
    out.println("}");
    closeJavaWriter(out);
}
Also used : RandomAccessFile(java.io.RandomAccessFile) Arrays(java.util.Arrays) TableRecordImpl(org.jooq.impl.TableRecordImpl) DSL(org.jooq.impl.DSL) SCALA(org.jooq.codegen.Language.SCALA) StringUtils.isBlank(org.jooq.tools.StringUtils.isBlank) Collectors.counting(java.util.stream.Collectors.counting) Internal(org.jooq.impl.Internal) POSTGRES(org.jooq.SQLDialect.POSTGRES) DatatypeConverter(jakarta.xml.bind.DatatypeConverter) AttributeDefinition(org.jooq.meta.AttributeDefinition) ColumnDefinition(org.jooq.meta.ColumnDefinition) RoutineDefinition(org.jooq.meta.RoutineDefinition) Matcher(java.util.regex.Matcher) IndexColumnDefinition(org.jooq.meta.IndexColumnDefinition) SelectField(org.jooq.SelectField) IdentityDefinition(org.jooq.meta.IdentityDefinition) Arrays.asList(java.util.Arrays.asList) Index(org.jooq.Index) Map(java.util.Map) BigInteger(java.math.BigInteger) SQLDialect(org.jooq.SQLDialect) Domain(org.jooq.Domain) Database(org.jooq.meta.Database) EmbeddableColumnDefinition(org.jooq.meta.EmbeddableColumnDefinition) CheckConstraintDefinition(org.jooq.meta.CheckConstraintDefinition) Set(java.util.Set) Constants(org.jooq.Constants) AggregateFunction(org.jooq.AggregateFunction) Result(org.jooq.Result) Collectors.joining(java.util.stream.Collectors.joining) GenerationOption(org.jooq.impl.QOM.GenerationOption) Stream(java.util.stream.Stream) TableField(org.jooq.TableField) SQLDataType(org.jooq.impl.SQLDataType) GeneratedAnnotationType(org.jooq.meta.jaxb.GeneratedAnnotationType) SequenceDefinition(org.jooq.meta.SequenceDefinition) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) Parameter(org.jooq.Parameter) TableDefinition(org.jooq.meta.TableDefinition) CatalogImpl(org.jooq.impl.CatalogImpl) IndexDefinition(org.jooq.meta.IndexDefinition) Sequence(org.jooq.Sequence) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Calendar(java.util.Calendar) Records(org.jooq.Records) Schema(org.jooq.Schema) BiConsumer(java.util.function.BiConsumer) RowId(org.jooq.RowId) LinkedHashSet(java.util.LinkedHashSet) MYSQL(org.jooq.SQLDialect.MYSQL) Record(org.jooq.Record) Mode(org.jooq.codegen.GeneratorStrategy.Mode) TypeVariable(java.lang.reflect.TypeVariable) IOException(java.io.IOException) StringUtils(org.jooq.tools.StringUtils) File(java.io.File) YUGABYTEDB(org.jooq.SQLDialect.YUGABYTEDB) VIRTUAL(org.jooq.impl.QOM.GenerationOption.VIRTUAL) SchemaDefinition(org.jooq.meta.SchemaDefinition) LazySupplier(org.jooq.impl.LazySupplier) TableImpl(org.jooq.impl.TableImpl) CatalogDefinition(org.jooq.meta.CatalogDefinition) UniqueKey(org.jooq.UniqueKey) Row(org.jooq.Row) IntStream.rangeClosed(java.util.stream.IntStream.rangeClosed) Time(java.sql.Time) Table(org.jooq.Table) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) DAOImpl(org.jooq.impl.DAOImpl) PackageDefinition(org.jooq.meta.PackageDefinition) DefaultDataType(org.jooq.impl.DefaultDataType) UDT(org.jooq.UDT) PostgresDatabase(org.jooq.meta.postgres.PostgresDatabase) SortOrder(org.jooq.SortOrder) DataType(org.jooq.DataType) DSL.name(org.jooq.impl.DSL.name) IdentityHashMap(java.util.IdentityHashMap) JooqLogger(org.jooq.tools.JooqLogger) SQLDialectNotSupportedException(org.jooq.exception.SQLDialectNotSupportedException) Collections.nCopies(java.util.Collections.nCopies) TimeZone(java.util.TimeZone) Name(org.jooq.Name) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) Check(org.jooq.Check) Field(org.jooq.Field) CloseResult(org.jooq.codegen.GeneratorWriter.CloseResult) PostgresRoutineDefinition(org.jooq.meta.postgres.PostgresRoutineDefinition) Collectors(java.util.stream.Collectors) UpdatableRecordImpl(org.jooq.impl.UpdatableRecordImpl) TypedElementDefinition(org.jooq.meta.TypedElementDefinition) JAVA(org.jooq.codegen.Language.JAVA) DomainDefinition(org.jooq.meta.DomainDefinition) Reflect(org.jooq.tools.reflect.Reflect) List(java.util.List) Modifier(java.lang.reflect.Modifier) Function.identity(java.util.function.Function.identity) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) IntStream(java.util.stream.IntStream) UniqueKeyDefinition(org.jooq.meta.UniqueKeyDefinition) KOTLIN(org.jooq.codegen.Language.KOTLIN) UDTField(org.jooq.UDTField) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) HashMap(java.util.HashMap) STORED(org.jooq.impl.QOM.GenerationOption.STORED) EnumType(org.jooq.EnumType) ForeignKey(org.jooq.ForeignKey) Function(java.util.function.Function) PackageImpl(org.jooq.impl.PackageImpl) Definition(org.jooq.meta.Definition) HashSet(java.util.HashSet) Identity(org.jooq.Identity) TableLike(org.jooq.TableLike) EmbeddableRecordImpl(org.jooq.impl.EmbeddableRecordImpl) EmbeddableDefinition(org.jooq.meta.EmbeddableDefinition) AbstractRoutine(org.jooq.impl.AbstractRoutine) Function2(org.jooq.Function2) ArrayDefinition(org.jooq.meta.ArrayDefinition) UDTDefinition(org.jooq.meta.UDTDefinition) AbstractTypedElementDefinition.getDataType(org.jooq.meta.AbstractTypedElementDefinition.getDataType) JavaTypeResolver(org.jooq.meta.JavaTypeResolver) ParameterDefinition(org.jooq.meta.ParameterDefinition) UDTRecordImpl(org.jooq.impl.UDTRecordImpl) ConstraintDefinition(org.jooq.meta.ConstraintDefinition) LazySchema(org.jooq.impl.LazySchema) DESC(org.jooq.SortOrder.DESC) SchemaImpl(org.jooq.impl.SchemaImpl) Date(java.sql.Date) ReflectException(org.jooq.tools.reflect.ReflectException) AbstractTypedElementDefinition(org.jooq.meta.AbstractTypedElementDefinition) Configuration(org.jooq.Configuration) Collectors.toList(java.util.stream.Collectors.toList) Catalog(org.jooq.Catalog) UDTImpl(org.jooq.impl.UDTImpl) StopWatch(org.jooq.tools.StopWatch) OrderField(org.jooq.OrderField) TableOptions(org.jooq.TableOptions) EnumDefinition(org.jooq.meta.EnumDefinition) ForeignKeyDefinition(org.jooq.meta.ForeignKeyDefinition) Collections(java.util.Collections) CheckConstraintDefinition(org.jooq.meta.CheckConstraintDefinition) Internal(org.jooq.impl.Internal) Schema(org.jooq.Schema) LazySchema(org.jooq.impl.LazySchema) TableImpl(org.jooq.impl.TableImpl) ArrayList(java.util.ArrayList) Check(org.jooq.Check) Index(org.jooq.Index) Name(org.jooq.Name) ForeignKeyDefinition(org.jooq.meta.ForeignKeyDefinition) SelectField(org.jooq.SelectField) TableField(org.jooq.TableField) Field(org.jooq.Field) UDTField(org.jooq.UDTField) OrderField(org.jooq.OrderField) TableOptions(org.jooq.TableOptions) IndexDefinition(org.jooq.meta.IndexDefinition) TableDefinition(org.jooq.meta.TableDefinition) Record(org.jooq.Record) Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) DSL(org.jooq.impl.DSL) Identity(org.jooq.Identity) Records(org.jooq.Records) Pattern(java.util.regex.Pattern) SchemaDefinition(org.jooq.meta.SchemaDefinition) Table(org.jooq.Table) EmbeddableColumnDefinition(org.jooq.meta.EmbeddableColumnDefinition) UniqueKeyDefinition(org.jooq.meta.UniqueKeyDefinition) SelectField(org.jooq.SelectField) IdentityDefinition(org.jooq.meta.IdentityDefinition) EmbeddableDefinition(org.jooq.meta.EmbeddableDefinition) AttributeDefinition(org.jooq.meta.AttributeDefinition) ColumnDefinition(org.jooq.meta.ColumnDefinition) RoutineDefinition(org.jooq.meta.RoutineDefinition) IndexColumnDefinition(org.jooq.meta.IndexColumnDefinition) IdentityDefinition(org.jooq.meta.IdentityDefinition) EmbeddableColumnDefinition(org.jooq.meta.EmbeddableColumnDefinition) CheckConstraintDefinition(org.jooq.meta.CheckConstraintDefinition) SequenceDefinition(org.jooq.meta.SequenceDefinition) TableDefinition(org.jooq.meta.TableDefinition) IndexDefinition(org.jooq.meta.IndexDefinition) SchemaDefinition(org.jooq.meta.SchemaDefinition) CatalogDefinition(org.jooq.meta.CatalogDefinition) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) PackageDefinition(org.jooq.meta.PackageDefinition) PostgresRoutineDefinition(org.jooq.meta.postgres.PostgresRoutineDefinition) TypedElementDefinition(org.jooq.meta.TypedElementDefinition) DomainDefinition(org.jooq.meta.DomainDefinition) UniqueKeyDefinition(org.jooq.meta.UniqueKeyDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) Definition(org.jooq.meta.Definition) EmbeddableDefinition(org.jooq.meta.EmbeddableDefinition) ArrayDefinition(org.jooq.meta.ArrayDefinition) UDTDefinition(org.jooq.meta.UDTDefinition) ParameterDefinition(org.jooq.meta.ParameterDefinition) ConstraintDefinition(org.jooq.meta.ConstraintDefinition) AbstractTypedElementDefinition(org.jooq.meta.AbstractTypedElementDefinition) EnumDefinition(org.jooq.meta.EnumDefinition) ForeignKeyDefinition(org.jooq.meta.ForeignKeyDefinition) ForeignKey(org.jooq.ForeignKey) TableField(org.jooq.TableField) ColumnDefinition(org.jooq.meta.ColumnDefinition) IndexColumnDefinition(org.jooq.meta.IndexColumnDefinition) EmbeddableColumnDefinition(org.jooq.meta.EmbeddableColumnDefinition) UniqueKey(org.jooq.UniqueKey) Arrays(java.util.Arrays) ParameterDefinition(org.jooq.meta.ParameterDefinition)

Example 3 with Definition

use of org.jooq.meta.Definition in project jOOQ by jOOQ.

the class JavaGenerator method printReferences.

protected void printReferences(JavaWriter out, List<? extends Definition> definitions, Class<?> type, boolean isGeneric) {
    if (out != null && !definitions.isEmpty()) {
        final String generic = isGeneric ? (scala ? "[_]" : kotlin ? "<*>" : "<?>") : "";
        final List<String> references = new ArrayList<>();
        final Definition first = definitions.get(0);
        // members in this class. Java can resolve the ambiguity.
        if ((scala || kotlin) && (first instanceof TableDefinition || first instanceof UDTDefinition)) {
            final Set<String> memberNames = getMemberNames(first.getSchema());
            for (Definition table : definitions) references.add(getShortId(out, memberNames, table));
        } else if ((scala || kotlin) && first instanceof SchemaDefinition) {
            final Set<String> memberNames = getMemberNames(first.getCatalog());
            for (Definition schema : definitions) references.add(getShortId(out, memberNames, schema));
        } else {
            references.addAll(kotlin ? out.ref(getStrategy().getFullJavaIdentifiers(definitions)) : out.ref(getStrategy().getFullJavaIdentifiers(definitions), 2));
        }
        out.println();
        if (scala) {
            if (definitions.size() > maxMembersPerInitialiser()) {
                out.println("%soverride def get%ss: %s[%s%s] = {", visibilityPublic(), type.getSimpleName(), List.class, type, generic);
                out.println("val result = new %s[%s%s]", ArrayList.class, type, generic);
                for (int i = 0; i < definitions.size(); i += maxMembersPerInitialiser()) out.println("result.addAll(get%ss%s)", type.getSimpleName(), i / maxMembersPerInitialiser());
                out.println("result");
                out.println("}");
            } else {
                out.println("%soverride def get%ss: %s[%s%s] = %s.asList[%s%s](", visibilityPublic(), type.getSimpleName(), List.class, type, generic, Arrays.class, type, generic);
                out.println("[[separator=,\n][%s]]", references);
                out.println(")");
            }
        } else if (kotlin) {
            if (definitions.size() > maxMembersPerInitialiser()) {
                out.println("%soverride fun get%ss(): %s<%s%s> {", visibilityPublic(), type.getSimpleName(), out.ref(KLIST), type, generic);
                out.println("val result = mutableListOf<%s%s>()", type, generic);
                for (int i = 0; i < definitions.size(); i += maxMembersPerInitialiser()) out.println("result.addAll(get%ss%s())", type.getSimpleName(), i / maxMembersPerInitialiser());
                out.println("return result");
                out.println("}");
            } else {
                out.println("%soverride fun get%ss(): %s<%s%s> = listOf(", visibilityPublic(), type.getSimpleName(), out.ref(KLIST), type, generic);
                out.println("[[separator=,\n][%s]]", references);
                out.println(")");
            }
        } else {
            out.override();
            printNonnullAnnotation(out);
            out.println("%sfinal %s<%s%s> get%ss() {", visibilityPublic(), List.class, type, generic, type.getSimpleName());
            if (definitions.size() > maxMembersPerInitialiser()) {
                out.println("%s result = new %s();", List.class, ArrayList.class);
                for (int i = 0; i < definitions.size(); i += maxMembersPerInitialiser()) out.println("result.addAll(get%ss%s());", type.getSimpleName(), i / maxMembersPerInitialiser());
                out.println("return result;");
            } else {
                out.println("return %s.asList(", Arrays.class);
                out.println("[[separator=,\n][%s]]", references);
                out.println(");");
            }
            out.println("}");
        }
        if (definitions.size() > maxMembersPerInitialiser()) {
            for (int i = 0; i < definitions.size(); i += maxMembersPerInitialiser()) {
                out.println();
                if (scala) {
                    out.println("private def get%ss%s(): %s[%s%s] = %s.asList[%s%s](", type.getSimpleName(), i / maxMembersPerInitialiser(), List.class, type, generic, Arrays.class, type, generic);
                    out.println("[[separator=,\n][%s]]", references.subList(i, Math.min(i + maxMembersPerInitialiser(), references.size())));
                    out.println(")");
                } else if (kotlin) {
                    out.println("private fun get%ss%s(): %s<%s%s> = listOf(", type.getSimpleName(), i / maxMembersPerInitialiser(), out.ref(KLIST), type, generic);
                    out.println("[[separator=,\n][%s]]", references.subList(i, Math.min(i + maxMembersPerInitialiser(), references.size())));
                    out.println(")");
                } else {
                    out.println("private final %s<%s%s> get%ss%s() {", List.class, type, generic, type.getSimpleName(), i / maxMembersPerInitialiser());
                    out.println("return %s.asList(", Arrays.class);
                    out.println("[[separator=,\n][%s]]", references.subList(i, Math.min(i + maxMembersPerInitialiser(), references.size())));
                    out.println(");");
                    out.println("}");
                }
            }
        }
    }
}
Also used : SchemaDefinition(org.jooq.meta.SchemaDefinition) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) AttributeDefinition(org.jooq.meta.AttributeDefinition) ColumnDefinition(org.jooq.meta.ColumnDefinition) RoutineDefinition(org.jooq.meta.RoutineDefinition) IndexColumnDefinition(org.jooq.meta.IndexColumnDefinition) IdentityDefinition(org.jooq.meta.IdentityDefinition) EmbeddableColumnDefinition(org.jooq.meta.EmbeddableColumnDefinition) CheckConstraintDefinition(org.jooq.meta.CheckConstraintDefinition) SequenceDefinition(org.jooq.meta.SequenceDefinition) TableDefinition(org.jooq.meta.TableDefinition) IndexDefinition(org.jooq.meta.IndexDefinition) SchemaDefinition(org.jooq.meta.SchemaDefinition) CatalogDefinition(org.jooq.meta.CatalogDefinition) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) PackageDefinition(org.jooq.meta.PackageDefinition) PostgresRoutineDefinition(org.jooq.meta.postgres.PostgresRoutineDefinition) TypedElementDefinition(org.jooq.meta.TypedElementDefinition) DomainDefinition(org.jooq.meta.DomainDefinition) UniqueKeyDefinition(org.jooq.meta.UniqueKeyDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) Definition(org.jooq.meta.Definition) EmbeddableDefinition(org.jooq.meta.EmbeddableDefinition) ArrayDefinition(org.jooq.meta.ArrayDefinition) UDTDefinition(org.jooq.meta.UDTDefinition) ParameterDefinition(org.jooq.meta.ParameterDefinition) ConstraintDefinition(org.jooq.meta.ConstraintDefinition) AbstractTypedElementDefinition(org.jooq.meta.AbstractTypedElementDefinition) EnumDefinition(org.jooq.meta.EnumDefinition) ForeignKeyDefinition(org.jooq.meta.ForeignKeyDefinition) TableDefinition(org.jooq.meta.TableDefinition) Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Arrays(java.util.Arrays) UDTDefinition(org.jooq.meta.UDTDefinition)

Example 4 with Definition

use of org.jooq.meta.Definition in project jOOQ by jOOQ.

the class JavaGenerator method generatePojo0.

private final void generatePojo0(Definition tableUdtOrEmbeddable, JavaWriter out) {
    final String className = getStrategy().getJavaClassName(tableUdtOrEmbeddable, Mode.POJO);
    final String interfaceName = generateInterfaces() ? out.ref(getStrategy().getFullJavaClassName(tableUdtOrEmbeddable, Mode.INTERFACE)) : "";
    final String superName = out.ref(getStrategy().getJavaClassExtends(tableUdtOrEmbeddable, Mode.POJO));
    final List<String> interfaces = out.ref(getStrategy().getJavaClassImplements(tableUdtOrEmbeddable, Mode.POJO));
    if (generateInterfaces())
        interfaces.add(interfaceName);
    final List<String> superTypes = list(superName, interfaces);
    printPackage(out, tableUdtOrEmbeddable, Mode.POJO);
    if (tableUdtOrEmbeddable instanceof TableDefinition)
        generatePojoClassJavadoc((TableDefinition) tableUdtOrEmbeddable, out);
    else if (tableUdtOrEmbeddable instanceof EmbeddableDefinition)
        generateEmbeddableClassJavadoc((EmbeddableDefinition) tableUdtOrEmbeddable, out);
    else
        generateUDTPojoClassJavadoc((UDTDefinition) tableUdtOrEmbeddable, out);
    printClassAnnotations(out, tableUdtOrEmbeddable, Mode.POJO);
    if (tableUdtOrEmbeddable instanceof TableDefinition)
        printTableJPAAnnotation(out, (TableDefinition) tableUdtOrEmbeddable);
    int maxLength0 = 0;
    for (TypedElementDefinition<?> column : getTypedElements(tableUdtOrEmbeddable)) maxLength0 = Math.max(maxLength0, out.ref(getJavaType(column.getType(resolver(out, Mode.POJO)), out, Mode.POJO)).length());
    int maxLength = maxLength0;
    if (scala) {
        out.println("%s%sclass %s(", visibility(), (generatePojosAsScalaCaseClasses() ? "case " : ""), className);
        forEach(getTypedElements(tableUdtOrEmbeddable), (column, separator) -> {
            out.println("%s%s %s: %s%s", visibility(generateInterfaces()), generateImmutablePojos() ? "val" : "var", scalaWhitespaceSuffix(getStrategy().getJavaMemberName(column, Mode.POJO)), out.ref(getJavaType(column.getType(resolver(out, Mode.POJO)), out, Mode.POJO)), separator);
        });
        out.println(")[[before= extends ][%s]][[before= with ][separator= with ][%s]] {", first(superTypes), remaining(superTypes));
    } else if (kotlin) {
        out.println("%s%sclass %s(", visibility(), (generatePojosAsKotlinDataClasses() ? "data " : ""), className);
        forEach(getTypedElements(tableUdtOrEmbeddable), (column, separator) -> {
            final String member = getStrategy().getJavaMemberName(column, Mode.POJO);
            if (column instanceof ColumnDefinition)
                printColumnJPAAnnotation(out, (ColumnDefinition) column);
            printValidationAnnotation(out, column);
            if (!generateImmutablePojos())
                printKotlinSetterAnnotation(out, column, Mode.POJO);
            out.println("%s%s%s %s: %s? = null%s", visibility(generateInterfaces()), generateInterfaces() ? "override " : "", generateImmutablePojos() ? "val" : "var", member, out.ref(getJavaType(column.getType(resolver(out, Mode.POJO)), out, Mode.POJO)), separator);
        });
        out.println(")[[before=: ][%s]] {", superTypes);
    } else {
        if (generatePojosAsJavaRecordClasses()) {
            out.println("%srecord %s(", visibility(), className);
            forEach(getTypedElements(tableUdtOrEmbeddable), (column, separator) -> {
                out.println("%s %s%s", StringUtils.rightPad(out.ref(getJavaType(column.getType(resolver(out, Mode.POJO)), out, Mode.POJO)), maxLength), getStrategy().getJavaMemberName(column, Mode.POJO), separator);
            });
            out.println(")[[before= implements ][%s]] {", interfaces);
        } else {
            out.println("%sclass %s[[before= extends ][%s]][[before= implements ][%s]] {", visibility(), className, list(superName), interfaces);
        }
        if (generateSerializablePojos() || generateSerializableInterfaces())
            out.printSerial();
        out.println();
        if (!generatePojosAsJavaRecordClasses())
            for (TypedElementDefinition<?> column : getTypedElements(tableUdtOrEmbeddable)) out.println("private %s%s %s;", generateImmutablePojos() ? "final " : "", StringUtils.rightPad(out.ref(getJavaType(column.getType(resolver(out, Mode.POJO)), out, Mode.POJO)), maxLength0), getStrategy().getJavaMemberName(column, Mode.POJO));
    }
    // Default constructor
    if (!generateImmutablePojos() && !generatePojosAsJavaRecordClasses())
        generatePojoDefaultConstructor(tableUdtOrEmbeddable, out);
    if (!kotlin) {
        if (!generatePojosAsJavaRecordClasses()) {
            // [#1363] [#7055] copy constructor
            generatePojoCopyConstructor(tableUdtOrEmbeddable, out);
            // Multi-constructor
            generatePojoMultiConstructor(tableUdtOrEmbeddable, out);
        }
        List<? extends TypedElementDefinition<?>> elements = getTypedElements(tableUdtOrEmbeddable);
        for (int i = 0; i < elements.size(); i++) {
            TypedElementDefinition<?> column = elements.get(i);
            if (!generatePojosAsJavaRecordClasses() || generateInterfaces())
                if (tableUdtOrEmbeddable instanceof TableDefinition)
                    generatePojoGetter(column, i, out);
                else
                    generateUDTPojoGetter(column, i, out);
            // Setter
            if (!generateImmutablePojos())
                if (tableUdtOrEmbeddable instanceof TableDefinition)
                    generatePojoSetter(column, i, out);
                else
                    generateUDTPojoSetter(column, i, out);
        }
    }
    if (tableUdtOrEmbeddable instanceof TableDefinition) {
        List<EmbeddableDefinition> embeddables = ((TableDefinition) tableUdtOrEmbeddable).getReferencedEmbeddables();
        for (int i = 0; i < embeddables.size(); i++) {
            EmbeddableDefinition embeddable = embeddables.get(i);
            if (!generateImmutablePojos())
                generateEmbeddablePojoSetter(embeddable, i, out);
            generateEmbeddablePojoGetter(embeddable, i, out);
        }
    }
    if (generatePojosEqualsAndHashCode())
        generatePojoEqualsAndHashCode(tableUdtOrEmbeddable, out);
    if (generatePojosToString())
        generatePojoToString(tableUdtOrEmbeddable, out);
    if (generateInterfaces() && !generateImmutablePojos())
        printFromAndInto(out, tableUdtOrEmbeddable, Mode.POJO);
    if (tableUdtOrEmbeddable instanceof TableDefinition)
        generatePojoClassFooter((TableDefinition) tableUdtOrEmbeddable, out);
    else if (tableUdtOrEmbeddable instanceof EmbeddableDefinition)
        generateEmbeddableClassFooter((EmbeddableDefinition) tableUdtOrEmbeddable, out);
    else
        generateUDTPojoClassFooter((UDTDefinition) tableUdtOrEmbeddable, out);
    out.println("}");
    closeJavaWriter(out);
}
Also used : RandomAccessFile(java.io.RandomAccessFile) Arrays(java.util.Arrays) TableRecordImpl(org.jooq.impl.TableRecordImpl) DSL(org.jooq.impl.DSL) SCALA(org.jooq.codegen.Language.SCALA) StringUtils.isBlank(org.jooq.tools.StringUtils.isBlank) Collectors.counting(java.util.stream.Collectors.counting) Internal(org.jooq.impl.Internal) POSTGRES(org.jooq.SQLDialect.POSTGRES) DatatypeConverter(jakarta.xml.bind.DatatypeConverter) AttributeDefinition(org.jooq.meta.AttributeDefinition) ColumnDefinition(org.jooq.meta.ColumnDefinition) RoutineDefinition(org.jooq.meta.RoutineDefinition) Matcher(java.util.regex.Matcher) IndexColumnDefinition(org.jooq.meta.IndexColumnDefinition) SelectField(org.jooq.SelectField) IdentityDefinition(org.jooq.meta.IdentityDefinition) Arrays.asList(java.util.Arrays.asList) Index(org.jooq.Index) Map(java.util.Map) BigInteger(java.math.BigInteger) SQLDialect(org.jooq.SQLDialect) Domain(org.jooq.Domain) Database(org.jooq.meta.Database) EmbeddableColumnDefinition(org.jooq.meta.EmbeddableColumnDefinition) CheckConstraintDefinition(org.jooq.meta.CheckConstraintDefinition) Set(java.util.Set) Constants(org.jooq.Constants) AggregateFunction(org.jooq.AggregateFunction) Result(org.jooq.Result) Collectors.joining(java.util.stream.Collectors.joining) GenerationOption(org.jooq.impl.QOM.GenerationOption) Stream(java.util.stream.Stream) TableField(org.jooq.TableField) SQLDataType(org.jooq.impl.SQLDataType) GeneratedAnnotationType(org.jooq.meta.jaxb.GeneratedAnnotationType) SequenceDefinition(org.jooq.meta.SequenceDefinition) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) Parameter(org.jooq.Parameter) TableDefinition(org.jooq.meta.TableDefinition) CatalogImpl(org.jooq.impl.CatalogImpl) IndexDefinition(org.jooq.meta.IndexDefinition) Sequence(org.jooq.Sequence) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Calendar(java.util.Calendar) Records(org.jooq.Records) Schema(org.jooq.Schema) BiConsumer(java.util.function.BiConsumer) RowId(org.jooq.RowId) LinkedHashSet(java.util.LinkedHashSet) MYSQL(org.jooq.SQLDialect.MYSQL) Record(org.jooq.Record) Mode(org.jooq.codegen.GeneratorStrategy.Mode) TypeVariable(java.lang.reflect.TypeVariable) IOException(java.io.IOException) StringUtils(org.jooq.tools.StringUtils) File(java.io.File) YUGABYTEDB(org.jooq.SQLDialect.YUGABYTEDB) VIRTUAL(org.jooq.impl.QOM.GenerationOption.VIRTUAL) SchemaDefinition(org.jooq.meta.SchemaDefinition) LazySupplier(org.jooq.impl.LazySupplier) TableImpl(org.jooq.impl.TableImpl) CatalogDefinition(org.jooq.meta.CatalogDefinition) UniqueKey(org.jooq.UniqueKey) Row(org.jooq.Row) IntStream.rangeClosed(java.util.stream.IntStream.rangeClosed) Time(java.sql.Time) Table(org.jooq.Table) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) DAOImpl(org.jooq.impl.DAOImpl) PackageDefinition(org.jooq.meta.PackageDefinition) DefaultDataType(org.jooq.impl.DefaultDataType) UDT(org.jooq.UDT) PostgresDatabase(org.jooq.meta.postgres.PostgresDatabase) SortOrder(org.jooq.SortOrder) DataType(org.jooq.DataType) DSL.name(org.jooq.impl.DSL.name) IdentityHashMap(java.util.IdentityHashMap) JooqLogger(org.jooq.tools.JooqLogger) SQLDialectNotSupportedException(org.jooq.exception.SQLDialectNotSupportedException) Collections.nCopies(java.util.Collections.nCopies) TimeZone(java.util.TimeZone) Name(org.jooq.Name) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) Check(org.jooq.Check) Field(org.jooq.Field) CloseResult(org.jooq.codegen.GeneratorWriter.CloseResult) PostgresRoutineDefinition(org.jooq.meta.postgres.PostgresRoutineDefinition) Collectors(java.util.stream.Collectors) UpdatableRecordImpl(org.jooq.impl.UpdatableRecordImpl) TypedElementDefinition(org.jooq.meta.TypedElementDefinition) JAVA(org.jooq.codegen.Language.JAVA) DomainDefinition(org.jooq.meta.DomainDefinition) Reflect(org.jooq.tools.reflect.Reflect) List(java.util.List) Modifier(java.lang.reflect.Modifier) Function.identity(java.util.function.Function.identity) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) IntStream(java.util.stream.IntStream) UniqueKeyDefinition(org.jooq.meta.UniqueKeyDefinition) KOTLIN(org.jooq.codegen.Language.KOTLIN) UDTField(org.jooq.UDTField) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) HashMap(java.util.HashMap) STORED(org.jooq.impl.QOM.GenerationOption.STORED) EnumType(org.jooq.EnumType) ForeignKey(org.jooq.ForeignKey) Function(java.util.function.Function) PackageImpl(org.jooq.impl.PackageImpl) Definition(org.jooq.meta.Definition) HashSet(java.util.HashSet) Identity(org.jooq.Identity) TableLike(org.jooq.TableLike) EmbeddableRecordImpl(org.jooq.impl.EmbeddableRecordImpl) EmbeddableDefinition(org.jooq.meta.EmbeddableDefinition) AbstractRoutine(org.jooq.impl.AbstractRoutine) Function2(org.jooq.Function2) ArrayDefinition(org.jooq.meta.ArrayDefinition) UDTDefinition(org.jooq.meta.UDTDefinition) AbstractTypedElementDefinition.getDataType(org.jooq.meta.AbstractTypedElementDefinition.getDataType) JavaTypeResolver(org.jooq.meta.JavaTypeResolver) ParameterDefinition(org.jooq.meta.ParameterDefinition) UDTRecordImpl(org.jooq.impl.UDTRecordImpl) ConstraintDefinition(org.jooq.meta.ConstraintDefinition) LazySchema(org.jooq.impl.LazySchema) DESC(org.jooq.SortOrder.DESC) SchemaImpl(org.jooq.impl.SchemaImpl) Date(java.sql.Date) ReflectException(org.jooq.tools.reflect.ReflectException) AbstractTypedElementDefinition(org.jooq.meta.AbstractTypedElementDefinition) Configuration(org.jooq.Configuration) Collectors.toList(java.util.stream.Collectors.toList) Catalog(org.jooq.Catalog) UDTImpl(org.jooq.impl.UDTImpl) StopWatch(org.jooq.tools.StopWatch) OrderField(org.jooq.OrderField) TableOptions(org.jooq.TableOptions) EnumDefinition(org.jooq.meta.EnumDefinition) ForeignKeyDefinition(org.jooq.meta.ForeignKeyDefinition) Collections(java.util.Collections) EmbeddableDefinition(org.jooq.meta.EmbeddableDefinition) TableDefinition(org.jooq.meta.TableDefinition) ColumnDefinition(org.jooq.meta.ColumnDefinition) IndexColumnDefinition(org.jooq.meta.IndexColumnDefinition) EmbeddableColumnDefinition(org.jooq.meta.EmbeddableColumnDefinition)

Example 5 with Definition

use of org.jooq.meta.Definition in project jOOQ by jOOQ.

the class JavaGenerator method generateRecord0.

private final void generateRecord0(Definition tableUdtOrEmbeddable, JavaWriter out) {
    final UniqueKeyDefinition key = (tableUdtOrEmbeddable instanceof TableDefinition) ? ((TableDefinition) tableUdtOrEmbeddable).getPrimaryKey() : null;
    final String className = getStrategy().getJavaClassName(tableUdtOrEmbeddable, Mode.RECORD);
    final String tableIdentifier = !(tableUdtOrEmbeddable instanceof EmbeddableDefinition) ? out.ref(getStrategy().getFullJavaIdentifier(tableUdtOrEmbeddable), 2) : null;
    final List<String> interfaces = out.ref(getStrategy().getJavaClassImplements(tableUdtOrEmbeddable, Mode.RECORD));
    printPackage(out, tableUdtOrEmbeddable, Mode.RECORD);
    if (tableUdtOrEmbeddable instanceof TableDefinition)
        generateRecordClassJavadoc((TableDefinition) tableUdtOrEmbeddable, out);
    else if (tableUdtOrEmbeddable instanceof EmbeddableDefinition)
        generateEmbeddableClassJavadoc((EmbeddableDefinition) tableUdtOrEmbeddable, out);
    else
        generateUDTRecordClassJavadoc((UDTDefinition) tableUdtOrEmbeddable, out);
    printClassAnnotations(out, tableUdtOrEmbeddable, Mode.RECORD);
    if (tableUdtOrEmbeddable instanceof TableDefinition)
        printTableJPAAnnotation(out, (TableDefinition) tableUdtOrEmbeddable);
    Class<?> baseClass;
    if (tableUdtOrEmbeddable instanceof UDTDefinition)
        baseClass = UDTRecordImpl.class;
    else if (tableUdtOrEmbeddable instanceof EmbeddableDefinition)
        baseClass = EmbeddableRecordImpl.class;
    else if (generateRelations() && key != null)
        baseClass = UpdatableRecordImpl.class;
    else
        baseClass = TableRecordImpl.class;
    // [#10481] Use the types from replaced embeddables if applicable
    List<Definition> embeddablesAndColumns = embeddablesAndColumns(tableUdtOrEmbeddable);
    List<Definition> embeddablesAndUnreplacedColumns = embeddablesAndUnreplacedColumns(tableUdtOrEmbeddable);
    List<Definition> replacingEmbeddablesAndUnreplacedColumns = replacingEmbeddablesAndUnreplacedColumns(tableUdtOrEmbeddable);
    List<Definition> embeddablesOrColumns = embeddablesOrColumns(tableUdtOrEmbeddable);
    int degree = replacingEmbeddablesAndUnreplacedColumns.size();
    String rowType = null;
    String rowTypeRecord = null;
    // [#6072] Generate these super types only if configured to do so
    if (generateRecordsImplementingRecordN() && degree > 0 && degree <= Constants.MAX_ROW_DEGREE) {
        rowType = refRowType(out, replacingEmbeddablesAndUnreplacedColumns);
        if (scala)
            rowTypeRecord = out.ref(Record.class.getName() + degree) + "[" + rowType + "]";
        else
            rowTypeRecord = out.ref(Record.class.getName() + degree) + "<" + rowType + ">";
        interfaces.add(rowTypeRecord);
    }
    if (generateInterfaces())
        interfaces.add(out.ref(getStrategy().getFullJavaClassName(tableUdtOrEmbeddable, Mode.INTERFACE)));
    if (scala)
        if (tableUdtOrEmbeddable instanceof EmbeddableDefinition)
            out.println("%sclass %s extends %s[%s](%s.%s.getDataType.getRow)[[before= with ][separator= with ][%s]] {", visibility(), className, baseClass, className, out.ref(getStrategy().getFullJavaIdentifier(((EmbeddableDefinition) tableUdtOrEmbeddable).getTable()), 2), getStrategy().getJavaIdentifier(tableUdtOrEmbeddable), interfaces);
        else
            out.println("%sclass %s extends %s[%s](%s)[[before= with ][separator= with ][%s]] {", visibility(), className, baseClass, className, tableIdentifier, interfaces);
    else if (kotlin)
        if (tableUdtOrEmbeddable instanceof EmbeddableDefinition)
            out.println("%sopen class %s() : %s<%s>(%s.%s.dataType.row)[[before=, ][%s]] {", visibility(), className, baseClass, className, out.ref(getStrategy().getFullJavaIdentifier(((EmbeddableDefinition) tableUdtOrEmbeddable).getTable()), 2), getStrategy().getJavaIdentifier(tableUdtOrEmbeddable), interfaces);
        else
            out.println("%sopen class %s() : %s<%s>(%s)[[before=, ][%s]] {", visibility(), className, baseClass, className, tableIdentifier, interfaces);
    else
        out.println("%sclass %s extends %s<%s>[[before= implements ][%s]] {", visibility(), className, baseClass, className, interfaces);
    out.printSerial();
    for (Definition column : embeddablesAndUnreplacedColumns) {
        final int index = replacingEmbeddablesAndUnreplacedColumns.indexOf(column);
        if (column instanceof EmbeddableDefinition) {
            final EmbeddableDefinition embeddable = (EmbeddableDefinition) column;
            generateEmbeddableRecordSetter(embeddable, index, out);
            generateEmbeddableRecordGetter(embeddable, index, out);
        } else {
            final TypedElementDefinition<?> c = (TypedElementDefinition<?>) column;
            if (tableUdtOrEmbeddable instanceof TableDefinition) {
                generateRecordSetter(c, index, out);
                generateRecordGetter(c, index, out);
            } else if (tableUdtOrEmbeddable instanceof EmbeddableDefinition) {
                generateEmbeddableSetter(c, index, out);
                generateEmbeddableGetter(c, index, out);
            } else {
                generateUDTRecordSetter(c, index, out);
                generateUDTRecordGetter(c, index, out);
            }
        }
    }
    if (generateRelations() && key != null) {
        int keyDegree = key.getKeyColumns().size();
        if (keyDegree <= Constants.MAX_ROW_DEGREE) {
            final String recordNType = out.ref(Record.class.getName() + keyDegree);
            final String keyType = refRowType(out, key.getKeyColumns());
            out.header("Primary key information");
            if (scala) {
                out.println();
                out.println("%soverride def key: %s[%s] = super.key.asInstanceOf[ %s[%s] ]", visibilityPublic(), recordNType, keyType, recordNType, keyType);
            } else if (kotlin) {
                out.println();
                out.println("%soverride fun key(): %s<%s> = super.key() as %s<%s>", visibilityPublic(), recordNType, keyType, recordNType, keyType);
            } else {
                out.overrideInherit();
                printNonnullAnnotation(out);
                out.println("%s%s<%s> key() {", visibilityPublic(), recordNType, keyType);
                out.println("return (%s) super.key();", recordNType);
                out.println("}");
            }
        }
    }
    if (tableUdtOrEmbeddable instanceof UDTDefinition) {
        // [#799] Oracle UDT's can have member procedures
        for (RoutineDefinition routine : ((UDTDefinition) tableUdtOrEmbeddable).getRoutines()) {
            // Instance methods ship with a SELF parameter at the first position
            // [#1584] Static methods don't have that
            boolean instance = routine.getInParameters().size() > 0 && routine.getInParameters().get(0).getInputName().toUpperCase(getStrategy().getTargetLocale()).equals("SELF");
            try {
                if (!routine.isSQLUsable()) {
                    // Instance execute() convenience method
                    printConvenienceMethodProcedure(out, routine, instance);
                } else {
                    // Instance execute() convenience method
                    if (!routine.isAggregate()) {
                        printConvenienceMethodFunction(out, routine, instance);
                    }
                }
            } catch (Exception e) {
                log.error("Error while generating routine " + routine, e);
            }
        }
    }
    // [#3130] Invalid UDTs may have a degree of 0
    if (generateRecordsImplementingRecordN() && degree > 0 && degree <= Constants.MAX_ROW_DEGREE) {
        final String recordNType = out.ref(Row.class.getName() + degree);
        out.header("Record%s type implementation", degree);
        // fieldsRow()
        if (scala) {
            out.println();
            out.println("%soverride def fieldsRow: %s[%s] = super.fieldsRow.asInstanceOf[ %s[%s] ]", visibilityPublic(), recordNType, rowType, recordNType, rowType);
        } else if (kotlin) {
            out.println();
            out.println("%soverride fun fieldsRow(): %s<%s> = super.fieldsRow() as %s<%s>", visibilityPublic(), recordNType, rowType, recordNType, rowType);
        } else {
            out.overrideInherit();
            printNonnullAnnotation(out);
            out.println("%s%s<%s> fieldsRow() {", visibilityPublic(), recordNType, rowType);
            out.println("return (%s) super.fieldsRow();", recordNType);
            out.println("}");
        }
        // valuesRow()
        if (scala) {
            out.println();
            out.println("%soverride def valuesRow: %s[%s] = super.valuesRow.asInstanceOf[ %s[%s] ]", visibilityPublic(), recordNType, rowType, recordNType, rowType);
        } else if (kotlin) {
            out.println("%soverride fun valuesRow(): %s<%s> = super.valuesRow() as %s<%s>", visibilityPublic(), recordNType, rowType, recordNType, rowType);
        } else {
            out.overrideInherit();
            printNonnullAnnotation(out);
            out.println("%s%s<%s> valuesRow() {", visibilityPublic(), recordNType, rowType);
            out.println("return (%s) super.valuesRow();", recordNType);
            out.println("}");
        }
        // field[N]()
        for (int i = 1; i <= degree; i++) {
            Definition column = replacingEmbeddablesAndUnreplacedColumns.get(i - 1);
            if (column instanceof EmbeddableColumnDefinition)
                column = ((EmbeddableColumnDefinition) column).getReferencingColumn();
            final String colTypeFull = getJavaType(column, out);
            final String colType = out.ref(colTypeFull);
            final String colIdentifierFull = out.ref(getStrategy().getFullJavaIdentifier(column), colRefSegments(column));
            final String colIdentifier = getStrategy().getJavaIdentifier(column);
            if (scala) {
                printDeprecationIfUnknownType(out, colTypeFull);
                if (tableUdtOrEmbeddable instanceof EmbeddableDefinition)
                    out.println("%soverride def field%s: %s[%s] = field(%s).asInstanceOf[%s [%s] ]", visibilityPublic(), i, Field.class, colType, i - 1, Field.class, colType);
                else
                    out.println("%soverride def field%s: %s[%s] = %s", visibilityPublic(), i, Field.class, colType, colIdentifierFull);
            } else if (kotlin) {
                printDeprecationIfUnknownType(out, colTypeFull);
                if (tableUdtOrEmbeddable instanceof EmbeddableDefinition)
                    out.println("%soverride fun field%s(): %s<%s?> = field(%s) as %s<%s?>", visibilityPublic(), i, Field.class, colType, i - 1, Field.class, colType);
                else if (tableUdtOrEmbeddable instanceof UDTDefinition)
                    out.println("%soverride fun field%s(): %s<%s%s> = %s.%s", visibilityPublic(), i, Field.class, colType, column instanceof EmbeddableDefinition ? "" : "?", out.ref(getStrategy().getFullJavaIdentifier(((AttributeDefinition) column).getContainer()), 2), colIdentifier);
                else
                    out.println("%soverride fun field%s(): %s<%s%s> = %s", visibilityPublic(), i, Field.class, colType, column instanceof EmbeddableDefinition ? "" : "?", colIdentifierFull);
            } else {
                if (printDeprecationIfUnknownType(out, colTypeFull))
                    out.override();
                else
                    out.overrideInherit();
                printNonnullAnnotation(out);
                out.println("%s%s<%s> field%s() {", visibilityPublic(), Field.class, colType, i);
                if (tableUdtOrEmbeddable instanceof EmbeddableDefinition)
                    out.println("return (%s<%s>) field(%s);", Field.class, colType, i - 1);
                else
                    out.println("return %s;", colIdentifierFull);
                out.println("}");
            }
        }
        // component[N]()
        for (int i = 1; i <= degree; i++) {
            Definition column = replacingEmbeddablesAndUnreplacedColumns.get(i - 1);
            final String colTypeFull = getJavaType(column, out);
            final String colType = out.ref(colTypeFull);
            final String colGetter = getStrategy().getJavaGetterName(column, Mode.RECORD);
            final String colMember = getStrategy().getJavaMemberName(column, Mode.POJO);
            if (scala) {
                printDeprecationIfUnknownType(out, colTypeFull);
                out.println("%soverride def component%s: %s = %s", visibilityPublic(), i, colType, colGetter);
            } else if (kotlin) {
                printDeprecationIfUnknownType(out, colTypeFull);
                out.println("%soverride fun component%s(): %s? = %s", visibilityPublic(), i, colType, colMember);
            } else {
                if (printDeprecationIfUnknownType(out, colTypeFull))
                    out.override();
                else
                    out.overrideInherit();
                printNullableOrNonnullAnnotation(out, column);
                out.println("%s%s component%s() {", visibilityPublic(), colType, i);
                out.println("return %s();", colGetter);
                out.println("}");
            }
        }
        // value[N]()
        for (int i = 1; i <= degree; i++) {
            Definition column = replacingEmbeddablesAndUnreplacedColumns.get(i - 1);
            final String colTypeFull = getJavaType(column, out);
            final String colType = out.ref(colTypeFull);
            final String colGetter = getStrategy().getJavaGetterName(column, Mode.RECORD);
            final String colMember = getStrategy().getJavaMemberName(column, Mode.POJO);
            if (scala) {
                printDeprecationIfUnknownType(out, colTypeFull);
                out.println("%soverride def value%s: %s = %s", visibilityPublic(), i, colType, colGetter);
            } else if (kotlin) {
                printDeprecationIfUnknownType(out, colTypeFull);
                out.println("%soverride fun value%s(): %s? = %s", visibilityPublic(), i, colType, colMember);
            } else {
                if (printDeprecationIfUnknownType(out, colTypeFull))
                    out.override();
                else
                    out.overrideInherit();
                printNullableOrNonnullAnnotation(out, column);
                out.println("%s%s value%s() {", visibilityPublic(), colType, i);
                out.println("return %s();", colGetter);
                out.println("}");
            }
        }
        // value[N](T[N])
        for (int i = 1; i <= degree; i++) {
            Definition column = replacingEmbeddablesAndUnreplacedColumns.get(i - 1);
            final String colTypeFull = getJavaType(column, out);
            final String colType = out.ref(colTypeFull);
            final String colSetter = getStrategy().getJavaSetterName(column, Mode.RECORD);
            final String colMember = getStrategy().getJavaMemberName(column, Mode.POJO);
            if (scala) {
                out.println();
                printDeprecationIfUnknownType(out, colTypeFull);
                out.println("%soverride def value%s(value: %s): %s = {", visibilityPublic(), i, colType, className);
                out.println("%s(value)", colSetter);
                out.println("this");
                out.println("}");
            } else if (kotlin) {
                out.println();
                printDeprecationIfUnknownType(out, colTypeFull);
                out.println("%soverride fun value%s(value: %s%s): %s {", visibilityPublic(), i, colType, column instanceof EmbeddableDefinition ? "" : "?", className);
                out.println("this.%s = value", colMember);
                out.println("return this");
                out.println("}");
            } else {
                final String nullableAnnotation = nullableOrNonnullAnnotation(out, column);
                if (printDeprecationIfUnknownType(out, colTypeFull))
                    out.override();
                else
                    out.overrideInherit();
                printNonnullAnnotation(out);
                out.println("%s%s value%s([[before=@][after= ][%s]]%s value) {", visibilityPublic(), className, i, list(nullableAnnotation), varargsIfArray(colType));
                out.println("%s(value);", colSetter);
                out.println("return this;");
                out.println("}");
            }
        }
        List<String> arguments = new ArrayList<>(degree);
        List<String> calls = new ArrayList<>(degree);
        for (int i = 1; i <= degree; i++) {
            final Definition column = replacingEmbeddablesAndUnreplacedColumns.get(i - 1);
            final String colType = getJavaTypeRef(column, out);
            if (scala) {
                arguments.add("value" + i + " : " + colType);
                calls.add("this.value" + i + "(value" + i + ")");
            } else if (kotlin) {
                arguments.add("value" + i + ": " + colType + (column instanceof EmbeddableDefinition ? "" : "?"));
                calls.add("this.value" + i + "(value" + i + ")");
            } else {
                final String nullableAnnotation = nullableOrNonnullAnnotation(out, column);
                arguments.add((nullableAnnotation == null ? "" : "@" + nullableAnnotation + " ") + colType + " value" + i);
                calls.add("value" + i + "(value" + i + ");");
            }
        }
        if (scala) {
            out.println();
            out.println("%soverride def values([[%s]]): %s = {", visibilityPublic(), arguments, className);
            for (String call : calls) out.println(call);
            out.println("this");
            out.println("}");
        } else if (kotlin) {
            out.println();
            out.println("%soverride fun values([[%s]]): %s {", visibilityPublic(), arguments, className);
            for (String call : calls) out.println(call);
            out.println("return this");
            out.println("}");
        } else {
            out.overrideInherit();
            printNonnullAnnotation(out);
            out.println("%s%s values([[%s]]) {", visibilityPublic(), className, arguments);
            for (String call : calls) out.println(call);
            out.println("return this;");
            out.println("}");
        }
    }
    if (generateInterfaces())
        printFromAndInto(out, tableUdtOrEmbeddable, Mode.RECORD);
    if (scala || kotlin) {
    } else {
        out.header("Constructors");
        out.javadoc("Create a detached %s", className);
        out.println("%s%s() {", visibility(), className);
        if (tableUdtOrEmbeddable instanceof EmbeddableDefinition)
            out.println("super(%s.%s.getDataType().getRow());", out.ref(getStrategy().getFullJavaIdentifier(((EmbeddableDefinition) tableUdtOrEmbeddable).getTable()), 2), getStrategy().getJavaIdentifier(tableUdtOrEmbeddable));
        else
            out.println("super(%s);", tableIdentifier);
        out.println("}");
    }
    // [#3130] Invalid UDTs may have a degree of 0
    // [#3176] Avoid generating constructors for tables with more than 255 columns (Java's method argument limit)
    generateRecordConstructor(tableUdtOrEmbeddable, out, replacingEmbeddablesAndUnreplacedColumns, false);
    if (!replacingEmbeddablesAndUnreplacedColumns.equals(embeddablesOrColumns))
        generateRecordConstructor(tableUdtOrEmbeddable, out, embeddablesOrColumns, false);
    if (generatePojos())
        generateRecordConstructor(tableUdtOrEmbeddable, out, replacingEmbeddablesAndUnreplacedColumns, true);
    if (tableUdtOrEmbeddable instanceof TableDefinition)
        generateRecordClassFooter((TableDefinition) tableUdtOrEmbeddable, out);
    else if (tableUdtOrEmbeddable instanceof EmbeddableDefinition)
        generateEmbeddableClassFooter((EmbeddableDefinition) tableUdtOrEmbeddable, out);
    else
        generateUDTRecordClassFooter((UDTDefinition) tableUdtOrEmbeddable, out);
    out.println("}");
}
Also used : UDTRecordImpl(org.jooq.impl.UDTRecordImpl) RoutineDefinition(org.jooq.meta.RoutineDefinition) PostgresRoutineDefinition(org.jooq.meta.postgres.PostgresRoutineDefinition) TypedElementDefinition(org.jooq.meta.TypedElementDefinition) AbstractTypedElementDefinition(org.jooq.meta.AbstractTypedElementDefinition) EmbeddableColumnDefinition(org.jooq.meta.EmbeddableColumnDefinition) UniqueKeyDefinition(org.jooq.meta.UniqueKeyDefinition) EmbeddableDefinition(org.jooq.meta.EmbeddableDefinition) TableRecordImpl(org.jooq.impl.TableRecordImpl) AttributeDefinition(org.jooq.meta.AttributeDefinition) ColumnDefinition(org.jooq.meta.ColumnDefinition) RoutineDefinition(org.jooq.meta.RoutineDefinition) IndexColumnDefinition(org.jooq.meta.IndexColumnDefinition) IdentityDefinition(org.jooq.meta.IdentityDefinition) EmbeddableColumnDefinition(org.jooq.meta.EmbeddableColumnDefinition) CheckConstraintDefinition(org.jooq.meta.CheckConstraintDefinition) SequenceDefinition(org.jooq.meta.SequenceDefinition) TableDefinition(org.jooq.meta.TableDefinition) IndexDefinition(org.jooq.meta.IndexDefinition) SchemaDefinition(org.jooq.meta.SchemaDefinition) CatalogDefinition(org.jooq.meta.CatalogDefinition) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) PackageDefinition(org.jooq.meta.PackageDefinition) PostgresRoutineDefinition(org.jooq.meta.postgres.PostgresRoutineDefinition) TypedElementDefinition(org.jooq.meta.TypedElementDefinition) DomainDefinition(org.jooq.meta.DomainDefinition) UniqueKeyDefinition(org.jooq.meta.UniqueKeyDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) Definition(org.jooq.meta.Definition) EmbeddableDefinition(org.jooq.meta.EmbeddableDefinition) ArrayDefinition(org.jooq.meta.ArrayDefinition) UDTDefinition(org.jooq.meta.UDTDefinition) ParameterDefinition(org.jooq.meta.ParameterDefinition) ConstraintDefinition(org.jooq.meta.ConstraintDefinition) AbstractTypedElementDefinition(org.jooq.meta.AbstractTypedElementDefinition) EnumDefinition(org.jooq.meta.EnumDefinition) ForeignKeyDefinition(org.jooq.meta.ForeignKeyDefinition) ArrayList(java.util.ArrayList) AttributeDefinition(org.jooq.meta.AttributeDefinition) UpdatableRecordImpl(org.jooq.impl.UpdatableRecordImpl) UDTDefinition(org.jooq.meta.UDTDefinition) IOException(java.io.IOException) SQLDialectNotSupportedException(org.jooq.exception.SQLDialectNotSupportedException) ReflectException(org.jooq.tools.reflect.ReflectException) SelectField(org.jooq.SelectField) TableField(org.jooq.TableField) Field(org.jooq.Field) UDTField(org.jooq.UDTField) OrderField(org.jooq.OrderField) TableDefinition(org.jooq.meta.TableDefinition) Record(org.jooq.Record)

Aggregations

ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)5 LinkedHashSet (java.util.LinkedHashSet)5 AbstractTypedElementDefinition (org.jooq.meta.AbstractTypedElementDefinition)5 ArrayDefinition (org.jooq.meta.ArrayDefinition)5 AttributeDefinition (org.jooq.meta.AttributeDefinition)5 CatalogDefinition (org.jooq.meta.CatalogDefinition)5 CheckConstraintDefinition (org.jooq.meta.CheckConstraintDefinition)5 ColumnDefinition (org.jooq.meta.ColumnDefinition)5 ConstraintDefinition (org.jooq.meta.ConstraintDefinition)5 DataTypeDefinition (org.jooq.meta.DataTypeDefinition)5 DefaultDataTypeDefinition (org.jooq.meta.DefaultDataTypeDefinition)5 Definition (org.jooq.meta.Definition)5 DomainDefinition (org.jooq.meta.DomainDefinition)5 EmbeddableColumnDefinition (org.jooq.meta.EmbeddableColumnDefinition)5 EmbeddableDefinition (org.jooq.meta.EmbeddableDefinition)5 EnumDefinition (org.jooq.meta.EnumDefinition)5 ForeignKeyDefinition (org.jooq.meta.ForeignKeyDefinition)5 IdentityDefinition (org.jooq.meta.IdentityDefinition)5 IndexColumnDefinition (org.jooq.meta.IndexColumnDefinition)5