Class SqlColumnMapping

java.lang.Object
io.micronaut.data.model.schema.sql.SqlColumnMapping

@Internal public final class SqlColumnMapping extends Object
Represents a SQL database column mapped from persistent entity field.
Since:
4.13.0
Author:
radovanradic
  • Constructor Details

    • SqlColumnMapping

      public SqlColumnMapping(String name, DataType dataType, SqlDbType dbType, boolean primaryKey, Integer length, Integer precision, Integer scale, boolean required, boolean autoGenerated, GeneratedValue.Type generatedValueType, String definition, JsonDataType jsonDataType)
      Constructs a new Column instance.
      Parameters:
      name - the name of the column
      dataType - the data type of the column
      dbType - the database-specific type
      primaryKey - whether the column is a primary key
      length - the length of the column (optional)
      precision - the precision of the column (optional)
      scale - the scale of the column (optional)
      required - whether the column is required
      autoGenerated - whether the column is auto-generated
      generatedValueType - the type of generated value (optional)
      definition - the definition of the column (optional)
      jsonDataType - the JSON data type (optional)
    • SqlColumnMapping

      public SqlColumnMapping(String name, DataType dataType, SqlDbType dbType, boolean primaryKey, @Nullable @Nullable Integer length, boolean required, boolean autoGenerated, GeneratedValue.Type generatedValueType, String definition)
      Constructs a new Column instance with simplified parameters.
      Parameters:
      name - the name of the column
      dataType - the data type of the column
      dbType - the database-specific type code
      primaryKey - whether the column is a primary key
      length - the length of the column (optional)
      required - whether the column is required
      autoGenerated - whether the column is auto-generated
      generatedValueType - the type of generated value (optional)
      definition - the definition of the column (optional)
    • SqlColumnMapping

      public SqlColumnMapping(String name, DataType dataType, SqlDbType dbType, boolean primaryKey, @Nullable @Nullable Integer length, @Nullable @Nullable Integer precision, boolean required, boolean autoGenerated, GeneratedValue.Type generatedValueType, String definition)
      Constructs a new Column instance with additional precision parameter.
      Parameters:
      name - the name of the column
      dataType - the data type of the column
      dbType - the database-specific type code
      primaryKey - whether the column is a primary key
      length - the length of the column (optional)
      precision - the precision of the column (optional)
      required - whether the column is required
      autoGenerated - whether the column is auto-generated
      generatedValueType - the type of generated value (optional)
      definition - the definition of the column (optional)
  • Method Details

    • getName

      public String getName()
      Returns the name of the column.
      Returns:
      the name of the column
    • getDataType

      public DataType getDataType()
      Returns the data type of the column.
      Returns:
      the data type of the column
    • getDbType

      public SqlDbType getDbType()
      Returns the database-specific type of this column.
      Returns:
      the database-specific type of this column
    • isRequired

      public boolean isRequired()
      Returns whether the column is required.
      Returns:
      true if the column is required, false otherwise
    • isAutoGenerated

      public boolean isAutoGenerated()
      Indicates whether the column is automatically generated.
      Returns:
      true if the column is auto-generated, false otherwise
    • getGeneratedValueType

      public GeneratedValue.Type getGeneratedValueType()
      Returns the type of generated value for this column, if any.
      Returns:
      the type of generated value, or null if no generated value is defined
    • getDefinition

      public String getDefinition()
      Returns the definition of the column, if available.
      Returns:
      the definition of the column, or null if not specified
    • getSqlType

      @NonNull public @NonNull String getSqlType(Dialect dialect)
      Returns the SQL type representation of this column for the given dialect.
      Parameters:
      dialect - the SQL dialect to generate the type for
      Returns:
      the SQL type representation of this column