Module org.jooq
Package org.jooq

Interface Fields

All Known Subinterfaces:
CloseableResultQuery<R>, CommonTableExpression<R>, Cursor<R>, DeleteResultStep<R>, EmbeddableRecord<R>, InsertResultStep<R>, JSONTableColumnPathStep, JSONTableColumnsStep, QOM.CrossApply<R>, QOM.CrossJoin<R>, QOM.DataChangeDeltaTable<R>, QOM.DeleteReturning<R>, QOM.DerivedTable<R>, QOM.Dual, QOM.FullJoin<R>, QOM.GenerateSeries<T>, QOM.HintedTable<R>, QOM.InsertReturning<R>, QOM.Join<R>, QOM.JoinTable<R,J>, QOM.Lateral<R>, QOM.LeftAntiJoin<R>, QOM.LeftJoin<R>, QOM.LeftSemiJoin<R>, QOM.LinkedTable<R>, QOM.NaturalFullJoin<R>, QOM.NaturalJoin<R>, QOM.NaturalLeftJoin<R>, QOM.NaturalRightJoin<R>, QOM.OuterApply<R>, QOM.QualifiedJoin<R,J>, QOM.RightJoin<R>, QOM.RowsFrom, QOM.RowSubquery, QOM.StraightJoin<R>, QOM.TableAlias<R>, QOM.UpdateReturning<R>, QOM.Values<R>, QOM.WithOrdinalityTable<R>, QOM.WithTable<R>, QualifiedRecord<R>, Record, Record1<T1>, Record10<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>, Record11<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>, Record12<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>, Record13<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>, Record14<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>, Record15<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>, Record16<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>, Record17<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>, Record18<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>, Record19<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>, Record2<T1,T2>, Record20<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>, Record21<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>, Record22<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>, Record3<T1,T2,T3>, Record4<T1,T2,T3,T4>, Record5<T1,T2,T3,T4,T5>, Record6<T1,T2,T3,T4,T5,T6>, Record7<T1,T2,T3,T4,T5,T6,T7>, Record8<T1,T2,T3,T4,T5,T6,T7,T8>, Record9<T1,T2,T3,T4,T5,T6,T7,T8,T9>, RecordQualifier<R>, RecordType<R>, Result<R>, ResultQuery<R>, Row, Row1<T1>, Row10<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>, Row11<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>, Row12<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>, Row13<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>, Row14<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>, Row15<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>, Row16<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>, Row17<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>, Row18<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>, Row19<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>, Row2<T1,T2>, Row20<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>, Row21<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>, Row22<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>, Row3<T1,T2,T3>, Row4<T1,T2,T3,T4>, Row5<T1,T2,T3,T4,T5>, Row6<T1,T2,T3,T4,T5,T6>, Row7<T1,T2,T3,T4,T5,T6,T7>, Row8<T1,T2,T3,T4,T5,T6,T7,T8>, Row9<T1,T2,T3,T4,T5,T6,T7,T8,T9>, RowN, Select<R>, SelectConditionStep<R>, SelectConnectByAfterStartWithConditionStep<R>, SelectConnectByConditionStep<R>, SelectConnectByStep<R>, SelectCorrelatedSubqueryStep<R>, SelectDistinctOnStep<R>, SelectFinalStep<R>, SelectForJSONCommonDirectivesStep<R>, SelectForStep<R>, SelectForUpdateOfStep<R>, SelectForUpdateStep<R>, SelectForUpdateWaitStep<R>, SelectForXMLCommonDirectivesStep<R>, SelectForXMLPathDirectivesStep<R>, SelectForXMLRawDirectivesStep<R>, SelectFromStep<R>, SelectGroupByStep<R>, SelectHavingConditionStep<R>, SelectHavingStep<R>, SelectIntoStep<R>, SelectJoinStep<R>, SelectLimitAfterOffsetStep<R>, SelectLimitPercentAfterOffsetStep<R>, SelectLimitPercentStep<R>, SelectLimitStep<R>, SelectOffsetStep<R>, SelectOnConditionStep<R>, SelectOptionalOnStep<R>, SelectOptionStep<R>, SelectOrderByStep<R>, SelectQualifyConditionStep<R>, SelectQualifyStep<R>, SelectQuery<R>, SelectSeekLimitStep<R>, SelectSeekStep1<R,T1>, SelectSeekStep10<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>, SelectSeekStep11<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>, SelectSeekStep12<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>, SelectSeekStep13<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>, SelectSeekStep14<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>, SelectSeekStep15<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>, SelectSeekStep16<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>, SelectSeekStep17<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>, SelectSeekStep18<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>, SelectSeekStep19<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>, SelectSeekStep2<R,T1,T2>, SelectSeekStep20<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>, SelectSeekStep21<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>, SelectSeekStep22<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>, SelectSeekStep3<R,T1,T2,T3>, SelectSeekStep4<R,T1,T2,T3,T4>, SelectSeekStep5<R,T1,T2,T3,T4,T5>, SelectSeekStep6<R,T1,T2,T3,T4,T5,T6>, SelectSeekStep7<R,T1,T2,T3,T4,T5,T6,T7>, SelectSeekStep8<R,T1,T2,T3,T4,T5,T6,T7,T8>, SelectSeekStep9<R,T1,T2,T3,T4,T5,T6,T7,T8,T9>, SelectSeekStepN<R>, SelectSelectStep<R>, SelectStartWithStep<R>, SelectUnionStep<R>, SelectWhereStep<R>, SelectWindowStep<R>, SelectWithTiesAfterOffsetStep<R>, SelectWithTiesStep<R>, Table<R>, TableLike<R>, TableOnConditionStep<R>, TableOptionalOnStep<R>, TableRecord<R>, UDT<R>, UDTRecord<R>, UpdatableRecord<R>, UpdateResultStep<R>, XMLTableColumnPathStep, XMLTableColumnsStep
All Known Implementing Classes:
CustomRecord, CustomTable, DefaultBinding.SdoGeometryRecord, DefaultBinding.SdoPointTypeRecord, EmbeddableRecordImpl, TableImpl, TableRecordImpl, UDTImpl, UDTRecordImpl, UpdatableRecordImpl

public interface Fields
A common super type for various types that can provide a set of fields, similar to a Table or a Record.

Ambiguities

Fields may or may not be qualified. Independently of qualification, dialects may produce duplicate fields by name in top level queries, e.g.:

 
 SELECT 1 AS id, 2 AS id, public.a.id
 FROM public.a
 
 

In the above unfortunate example, there are 3 ambiguous ID columns. Only one of them is qualified as A.ID, whereas the other two are unqualified aliases that cannot be distinguished by name, only by index. The behaviour of the various field access methods can be summarised as follows:

  • field(int) will return the expected field by index and isn't affected by this situation.
  • field(String) (case sensitive) works only with unqualified field names, and can thus not distinguish between any of the 3 fields. It will pick the first match.
  • field(Name) (case sensitive) works with unqualified or qualified field names. Depending on whether qualification is available in the jOOQ result (e.g. it might not be if you're using plain SQL templating, and the JDBC driver isn't able to produce the qualification), the qualification information will be used to disambiguate the result. Specifically:
    • If the argument Name is e.g. PUBLIC.A.ID (exact match) or X.A.ID, or A.ID (partial match), then those matches will be preferred over the unqualified match candidates
    • If the argument Name is ID, then the name continues to be ambiguous, and the first value will be returned.
  • field(Field) works like field(Name), except an additional Field identity check will be used to disambiguate field references. This is particularly useful when using generated code.

Whenever an ambiguity is encountered, a warning is logged to help debug the case. Future jOOQ versions might throw an exception upon ambiguity.

Unknown fields

Not all implementations actually know their fields. For example, when using plain SQL templates (DSL.field(String)) or tables constructed from identifiers (DSL.field(Name)), then the fields are unknown to jOOQ and empty lists or arrays are returned, or null is returned on single field returning methods.

Author:
Lukas Eder
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable DataType<?>
    dataType(int index)
    Get the field data type for a given field index, or null if no field is available at the index.
    @Nullable DataType<?>
    Get the field data type for a given qualified field name, or null if no field is known to this type by this name.
    @Nullable DataType<?>
    dataType(Name name)
    Get the field data type for a given qualified field name, or null if no field is known to this type by this name.
    @NotNull DataType<?> @NotNull []
    Get an array of field data types for this type.
    @Nullable Field<?>
    field(int index)
    Get a field known to this type by index, or null if no field is available at the index.
    <T> @Nullable Field<T>
    field(int index, Class<T> type)
    Get a field known to this type by index coerced to type, or null if no field is available at the index.
    <T> @Nullable Field<T>
    field(int index, DataType<T> dataType)
    Get a field known to this type by index coerced to dataType, or null if no field is available at the index.
    @Nullable Field<?>
    field(String name)
    Get a field known to this type by unqualified name, or null if no field is known to this type by this name.
    <T> @Nullable Field<T>
    field(String name, Class<T> type)
    Get a field known to this type by unqualified name coerced to type, or null if no field is known to this type by this name.
    <T> @Nullable Field<T>
    field(String name, DataType<T> dataType)
    Get a field known to this type by unqualified name coerced to dataType, or null if no field is known to this type by this name.
    <T> @Nullable Field<T>
    field(Field<T> field)
    Get a field known to this type by field reference.
    @Nullable Field<?>
    field(Name name)
    Get a field known to this type by qualified name, or null if no field is known to this type by this name.
    <T> @Nullable Field<T>
    field(Name name, Class<T> type)
    Get a field known to this type by qualified name coerced to type, or null if no field is known to this type by this name.
    <T> @Nullable Field<T>
    field(Name name, DataType<T> dataType)
    Get a field known to this type by qualified name coerced to dataType, or null if no field is known to this type by this name.
    @NotNull Field<?> @NotNull []
    Get all fields known to this type.
    @Nullable Field<?> @NotNull []
    fields(int... indexes)
    Get all fields known to this type, filtering by some field indexes.
    @Nullable Field<?> @NotNull []
    fields(String... names)
    Get all fields known to this type, filtering by some unqualified field names.
    @Nullable Field<?> @NotNull []
    fields(Field<?>... fields)
    Get all fields, filtering by some fields.
    @Nullable Field<?> @NotNull []
    fields(Name... names)
    Get all fields known to this type, filtering by some qualified field names.
    @NotNull Row
    Get all fields known to this type as a Row.
    @NotNull Stream<Field<?>>
    Get all fields known to this type as a Stream.
    int
    Get a field's index from this type.
    int
    indexOf(Field<?> field)
    Get a field's index from this type.
    int
    indexOf(Name name)
    Get a field's index from this type.
    @Nullable Class<?>
    type(int index)
    Get the field type for a given field index, or null if no field is available at the index.
    @Nullable Class<?>
    type(String name)
    Get the field type for a given unqualified field name, or null if no field is known to this type by this name.
    @Nullable Class<?>
    type(Name name)
    Get the field type for a given qualified field name, or null if no field is known to this type by this name.
    @NotNull Class<?> @NotNull []
    Get an array of field types for fields known to this type.
  • Method Details

    • fields

      @NotNull @NotNull Field<?> @NotNull [] fields()
      Get all fields known to this type.
    • fieldsRow

      @NotNull @NotNull Row fieldsRow()
      Get all fields known to this type as a Row.
    • fieldStream

      @NotNull @NotNull Stream<Field<?>> fieldStream()
      Get all fields known to this type as a Stream.
    • field

      @Nullable <T> @Nullable Field<T> field(Field<T> field)
      Get a field known to this type by field reference.

      This will return:

      • A field that is the same as the argument field (by identity comparison).
      • A field that is equal to the argument field (exact matching fully qualified name).
      • A field that is equal to the argument field (partially matching qualified name).
      • A field whose name is equal to the unqualified name of the argument field.
      • null otherwise.

      If several fields have the same ambiguous name, the first one is returned and a warning is logged.

    • field

      @Nullable @Nullable Field<?> field(String name)
      Get a field known to this type by unqualified name, or null if no field is known to this type by this name.

      If several fields have the same ambiguous name, the first one is returned and a warning is logged.

      Parameters:
      name - The unqualified name of the field
    • field

      @Nullable <T> @Nullable Field<T> field(String name, Class<T> type)
      Get a field known to this type by unqualified name coerced to type, or null if no field is known to this type by this name.

      If several fields have the same ambiguous name, the first one is returned and a warning is logged.

      Parameters:
      name - The unqualified name of the field
      type - The type to coerce the resulting field to
    • field

      @Nullable <T> @Nullable Field<T> field(String name, DataType<T> dataType)
      Get a field known to this type by unqualified name coerced to dataType, or null if no field is known to this type by this name.

      If several fields have the same ambiguous name, the first one is returned and a warning is logged.

      Parameters:
      name - The unqualified name of the field
      dataType - The data type to coerce the resulting field to
    • field

      @Nullable @Nullable Field<?> field(Name name)
      Get a field known to this type by qualified name, or null if no field is known to this type by this name.

      This will return:

      • A field whose name is equal to the argument field's name (exact matching fully qualified name).
      • A field whose name is equal to the argument field's name (partially matching qualified name).
      • A field whose name is equal to the unqualified name of the argument field.
      • null otherwise.

      If several fields have the same ambiguous name, the first one is returned and a warning is logged.

      Parameters:
      name - The qualified name of the field
    • field

      @Nullable <T> @Nullable Field<T> field(Name name, Class<T> type)
      Get a field known to this type by qualified name coerced to type, or null if no field is known to this type by this name.

      This will return:

      • A field whose name is equal to the argument field's name (exact matching fully qualified name).
      • A field whose name is equal to the argument field's name (partially matching qualified name).
      • A field whose name is equal to the unqualified name of the argument field.
      • null otherwise.

      If several fields have the same ambiguous name, the first one is returned and a warning is logged.

      Parameters:
      name - The qualified name of the field
      type - The type to coerce the resulting field to
    • field

      @Nullable <T> @Nullable Field<T> field(Name name, DataType<T> dataType)
      Get a field known to this type by qualified name coerced to dataType, or null if no field is known to this type by this name.

      This will return:

      • A field whose name is equal to the argument field's name (exact matching fully qualified name).
      • A field whose name is equal to the argument field's name (partially matching qualified name).
      • A field whose name is equal to the unqualified name of the argument field.
      • null otherwise.

      If several fields have the same ambiguous name, the first one is returned and a warning is logged.

      Parameters:
      name - The qualified name of the field
      dataType - The data type to coerce the resulting field to
    • field

      @Nullable @Nullable Field<?> field(int index)
      Get a field known to this type by index, or null if no field is available at the index.
      Parameters:
      index - The 0-based index of the field
    • field

      @Nullable <T> @Nullable Field<T> field(int index, Class<T> type)
      Get a field known to this type by index coerced to type, or null if no field is available at the index.
      Parameters:
      index - The 0-based index of the field
      type - The type to coerce the resulting field to
    • field

      @Nullable <T> @Nullable Field<T> field(int index, DataType<T> dataType)
      Get a field known to this type by index coerced to dataType, or null if no field is available at the index.
      Parameters:
      index - The 0-based index of the field
      dataType - The data type to coerce the resulting field to
    • fields

      @Nullable @Nullable Field<?> @NotNull [] fields(Field<?>... fields)
      Get all fields, filtering by some fields.
      Parameters:
      fields - The fields to include after looking them up via field(Field).
      See Also:
    • fields

      @Nullable @Nullable Field<?> @NotNull [] fields(String... names)
      Get all fields known to this type, filtering by some unqualified field names.
      Parameters:
      names - The unqualified field names to include after looking them up via field(String).
      See Also:
    • fields

      @Nullable @Nullable Field<?> @NotNull [] fields(Name... names)
      Get all fields known to this type, filtering by some qualified field names.
      Parameters:
      names - The qualified field names to include after looking them up via field(Name).
      See Also:
    • fields

      @Nullable @Nullable Field<?> @NotNull [] fields(int... indexes)
      Get all fields known to this type, filtering by some field indexes.
      Parameters:
      names - The 0-based field indexes to include after looking them up via field(int).
      See Also:
    • indexOf

      int indexOf(Field<?> field)
      Get a field's index from this type.

      The lookup algorithm is the same as that of field(Field).

      Parameters:
      field - The field to look for
      Returns:
      The field's 0-based index or -1 if the field is not known to this type.
    • indexOf

      int indexOf(String name)
      Get a field's index from this type.

      The lookup algorithm is the same as that of field(String).

      Parameters:
      name - The unqualified field name to look for
      Returns:
      The field's 0-based index or -1 if the field is not known to this type.
    • indexOf

      int indexOf(Name name)
      Get a field's index from this type.

      The lookup algorithm is the same as that of field(Name).

      Parameters:
      name - The qualified field name to look for
      Returns:
      The field's 0-based index or -1 if the field is not known to this type.
    • types

      @NotNull @NotNull Class<?> @NotNull [] types()
      Get an array of field types for fields known to this type.

      Entries in the resulting array correspond to Typed.getType() for the corresponding Field in fields()

    • type

      @Nullable @Nullable Class<?> type(int index)
      Get the field type for a given field index, or null if no field is available at the index.
      Parameters:
      index - The field's 0-based index
    • type

      @Nullable @Nullable Class<?> type(String name)
      Get the field type for a given unqualified field name, or null if no field is known to this type by this name.

      The lookup algorithm is the same as that of field(String).

      Parameters:
      name - The unqualified field name
    • type

      @Nullable @Nullable Class<?> type(Name name)
      Get the field type for a given qualified field name, or null if no field is known to this type by this name.

      The lookup algorithm is the same as that of field(Name).

      Parameters:
      name - The qualified field name
    • dataTypes

      @NotNull @NotNull DataType<?> @NotNull [] dataTypes()
      Get an array of field data types for this type.

      Entries in the resulting array correspond to Typed.getDataType() for the corresponding Field in fields()

    • dataType

      @Nullable @Nullable DataType<?> dataType(int index)
      Get the field data type for a given field index, or null if no field is available at the index.
      Parameters:
      index - The field's 0-based index
    • dataType

      @Nullable @Nullable DataType<?> dataType(String name)
      Get the field data type for a given qualified field name, or null if no field is known to this type by this name.

      The lookup algorithm is the same as that of field(String).

      Parameters:
      name - The qualified field name
    • dataType

      @Nullable @Nullable DataType<?> dataType(Name name)
      Get the field data type for a given qualified field name, or null if no field is known to this type by this name.

      The lookup algorithm is the same as that of field(Name).

      Parameters:
      name - The qualified field name