Class JdbcTableColumn

java.lang.Object
com.northconcepts.datapipeline.foundations.core.Bean
com.northconcepts.datapipeline.foundations.jdbc.JdbcTableColumn
All Implemented Interfaces:
DataExceptionContributor, JsonSerializable, RecordSerializable, XmlSerializable, Serializable

public class JdbcTableColumn extends Bean
Metadata for a column of a JdbcTable, read from JDBC DatabaseMetaData by JdbcConnection.loadTables(LoadTablesRequest).
See Also:
  • Field Details

  • Constructor Details

    • JdbcTableColumn

      public JdbcTableColumn()
  • Method Details

    • getTable

      public JdbcTable getTable()
      Returns the table this column was added to, or null.
    • setTable

      protected JdbcTableColumn setTable(JdbcTable table)
      Sets the table this column belongs to; called by JdbcTable.addColumn(JdbcTableColumn).
    • getName

      public String getName()
    • setName

      public JdbcTableColumn setName(String name)
    • getNameAsJavaClassName

      public String getNameAsJavaClassName()
      Returns the name as a camel-case Java class name, e.g. FirstName for FIRST_NAME.
    • getNameAsJavaIdentifier

      public String getNameAsJavaIdentifier()
      Returns the name as a camel-case Java identifier, e.g. firstName for FIRST_NAME.
    • getSqlTypeIndex

      public int getSqlTypeIndex()
      SQL type from Types
    • setSqlTypeIndex

      public JdbcTableColumn setSqlTypeIndex(int sqlTypeIndex)
      SQL type from Types
    • isBinarySqlType

      public boolean isBinarySqlType()
      Returns true if the SQL type is BLOB, BINARY, VARBINARY or LONGVARBINARY.
    • isTextSqlType

      public boolean isTextSqlType()
      Returns true if the SQL type is CHAR, VARCHAR, LONGVARCHAR, their national (N) variants, CLOB or NCLOB.
    • isNumericSqlType

      public boolean isNumericSqlType()
      Returns true if the SQL type is BIGINT, DECIMAL, DOUBLE, FLOAT, INTEGER, NUMERIC, REAL, SMALLINT or TINYINT.
    • isBooleanSqlType

      public boolean isBooleanSqlType()
      Returns true if the SQL type is BIT or BOOLEAN.
    • isTemporalSqlType

      public boolean isTemporalSqlType()
      Returns true if the SQL type is DATE, TIME, TIMESTAMP, TIME_WITH_TIMEZONE or TIMESTAMP_WITH_TIMEZONE.
    • isRealNumber

      public boolean isRealNumber()
      Returns true if columns of this type are numbers that can contain fractions.
    • isIntegerNumber

      public boolean isIntegerNumber()
      Returns true if columns of this type are numbers that cannot contain fractions (byte, short, int, etc.).
    • isExactNumber

      public boolean isExactNumber()
      Returns true if values of this type are numbers that contain exact quantities (BIGINT, DECIMAL, INTEGER, NUMERIC, SMALLINT, TINYINT, SMALLINT).
    • isApproximateNumber

      public boolean isApproximateNumber()
      Returns true if values of this type are numbers that do not contain exact quantities (DOUBLE, FLOAT, or REAL).
    • getDatabaseTypeName

      public String getDatabaseTypeName()
    • setDatabaseTypeName

      public JdbcTableColumn setDatabaseTypeName(String databaseTypeName)
    • getSize

      public int getSize()
      Returns the column size: the precision for numbers, the length in characters for text and in bytes for binary data.
    • setSize

      public JdbcTableColumn setSize(int size)
      Sets the column size: the precision for numbers, the length in characters for text and in bytes for binary data.
    • getDecimals

      public int getDecimals()
      Returns the number of fractional digits (0 where not applicable).
    • setDecimals

      public JdbcTableColumn setDecimals(int decimals)
      Sets the number of fractional digits (0 where not applicable).
    • getRadix

      public int getRadix()
      Returns the radix of the size and decimals, typically 10 or 2.
    • setRadix

      public JdbcTableColumn setRadix(int radix)
      Sets the radix of the size and decimals, typically 10 or 2.
    • isNullable

      public boolean isNullable()
      Indicates if the column is known to allow nulls (false when the database reports no nulls or unknown).
    • setNullable

      public JdbcTableColumn setNullable(boolean nullable)
      Indicates if the column is known to allow nulls (false when the database reports no nulls or unknown).
    • getRemarks

      public String getRemarks()
    • setRemarks

      public JdbcTableColumn setRemarks(String remarks)
    • getDefaultValue

      public String getDefaultValue()
      Returns the column's default value as unparsed text reported by the database, or null.
    • setDefaultValue

      public JdbcTableColumn setDefaultValue(String defaultValue)
      Sets the column's default value as unparsed text reported by the database.
    • isNullDefaultValue

      public boolean isNullDefaultValue()
      Returns true if the default value is null or the string "NULL".
      Returns:
      true if the default value is null or "NULL", false otherwise
    • isEmptyDefaultValue

      public boolean isEmptyDefaultValue()
      Returns true if the default value is an empty string or the string "''".
      Returns:
      true if the default value is empty or "''", false otherwise
    • getDefaultValueAsJavaString

      public String getDefaultValueAsJavaString()
      Converts the default value to a Java string literal suitable for code generation.

      Returns null if the default value is null or "NULL", returns "" for empty strings, properly escapes text SQL types, and returns the default value as-is for primitive types. For non-primitive and non-string types, returns null.

      Returns:
      the default value as a Java string literal, or null if not convertible
    • getByteCount

      public int getByteCount()
      Returns the maximum length in bytes of a character column (JDBC CHAR_OCTET_LENGTH).
    • setByteCount

      public JdbcTableColumn setByteCount(int byteCount)
      Sets the maximum length in bytes of a character column (JDBC CHAR_OCTET_LENGTH).
    • getIndex

      public int getIndex()
      Index of column in table (starting at 1).
    • setIndex

      public JdbcTableColumn setIndex(int index)
      Index of column in table (starting at 1).
    • isAutoIncrement

      public boolean isAutoIncrement()
    • setAutoIncrement

      public JdbcTableColumn setAutoIncrement(boolean autoIncrement)
    • isGenerated

      public boolean isGenerated()
      Indicates if the column is a generated (computed) column.
    • setGenerated

      public JdbcTableColumn setGenerated(boolean generated)
      Indicates if the column is a generated (computed) column.
    • isPseudo

      public boolean isPseudo()
      Indicates if the column is a pseudo column, like an Oracle ROWID, reported as part of the best row identifier.
    • setPseudo

      public JdbcTableColumn setPseudo(boolean pseudo)
      Indicates if the column is a pseudo column, like an Oracle ROWID, reported as part of the best row identifier.
    • getJavaType

      public Class<?> getJavaType()
      Returns the Java type for the column's values, chosen from the connection's type overrides or SQL-to-Java type mapper.
    • setJavaType

      public JdbcTableColumn setJavaType(Class<?> javaType)
      Sets the Java type for the column's values, normally chosen when the table's columns are loaded.
    • getFieldType

      public FieldType getFieldType()
      Returns the FieldType corresponding to this column's Java type.

      If the Java type cannot be mapped to a FieldType, returns FieldType.UNDEFINED.

      Returns:
      the field type for this column, or FieldType.UNDEFINED if not mappable
    • getMethodSuffix

      public String getMethodSuffix()
      Returns the ResultSet and PreparedStatement accessor suffix for the Java type, e.g. Int for getInt and setInt.
    • getGetterMethod

      public String getGetterMethod()
      Returns the bean getter name for this column, e.g. getFirstName, or isActive for a primitive boolean.
    • getSetterMethod

      public String getSetterMethod()
      Returns the bean setter name for this column, e.g. setFirstName.
    • getPrimaryKeySequence

      public Integer getPrimaryKeySequence()
      Starting at 1.
    • setPrimaryKeySequence

      public JdbcTableColumn setPrimaryKeySequence(Integer primaryKeySequence)
      Sets the column's 1-based position in the primary key, or null if it is not part of it.
    • isPrimaryKey

      public boolean isPrimaryKey()
    • getRowIdentifierSequence

      public Integer getRowIdentifierSequence()
      Returns the column's 1-based position in the table's best row identifier, or null if it is not part of it.
    • setRowIdentifierSequence

      public JdbcTableColumn setRowIdentifierSequence(Integer rowIdentifierSequence)
      Sets the column's 1-based position in the table's best row identifier, or null if it is not part of it.
    • isRowIdentifier

      public boolean isRowIdentifier()
      Returns true if the column is part of the table's best row identifier (the columns that uniquely identify a row).
    • getClassName

      public String getClassName()
      Returns the fully-qualified class name of the values the JDBC driver returns for this column.
    • setClassName

      public JdbcTableColumn setClassName(String className)
      Sets the fully-qualified class name of the values the JDBC driver returns for this column.
    • isSigned

      public boolean isSigned()
    • setSigned

      public JdbcTableColumn setSigned(boolean signed)
    • toRecord

      public Record toRecord()
      Description copied from interface: RecordSerializable
      Converts this object's state to a record that RecordSerializable.fromRecord(Record) can load.
      Specified by:
      toRecord in interface RecordSerializable
      Overrides:
      toRecord in class Bean
    • fromRecord

      public JdbcTableColumn fromRecord(Record source)
      Description copied from interface: RecordSerializable
      Loads this instance's state from a record and returns this (for fluid API call chaining). For fluid API call chaining, the overridden method should change the declared return type to its class.
      Specified by:
      fromRecord in interface RecordSerializable
      Overrides:
      fromRecord in class Bean
      Parameters:
      source -
      Returns:
      this instance.