Class SqlColumnMapping
java.lang.Object
io.micronaut.data.model.schema.sql.SqlColumnMapping
Represents a SQL database column mapped from persistent entity field.
- Since:
- 4.13.0
- Author:
- radovanradic
-
Constructor Summary
ConstructorsConstructorDescriptionSqlColumnMapping
(String name, DataType dataType, SqlDbType dbType, boolean primaryKey, @Nullable Integer length, boolean required, boolean autoGenerated, GeneratedValue.Type generatedValueType, String definition) Constructs a new Column instance with simplified parameters.SqlColumnMapping
(String name, DataType dataType, SqlDbType dbType, boolean primaryKey, @Nullable Integer length, @Nullable Integer precision, boolean required, boolean autoGenerated, GeneratedValue.Type generatedValueType, String definition) Constructs a new Column instance with additional precision parameter.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. -
Method Summary
Modifier and TypeMethodDescriptionReturns the data type of the column.Returns the database-specific type of this column.Returns the definition of the column, if available.Returns the type of generated value for this column, if any.getName()
Returns the name of the column.@NonNull String
getSqlType
(Dialect dialect) Returns the SQL type representation of this column for the given dialect.boolean
Indicates whether the column is automatically generated.boolean
Returns whether the column is required.
-
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 columndataType
- the data type of the columndbType
- the database-specific typeprimaryKey
- whether the column is a primary keylength
- 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 requiredautoGenerated
- whether the column is auto-generatedgeneratedValueType
- 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 columndataType
- the data type of the columndbType
- the database-specific type codeprimaryKey
- whether the column is a primary keylength
- the length of the column (optional)required
- whether the column is requiredautoGenerated
- whether the column is auto-generatedgeneratedValueType
- 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 columndataType
- the data type of the columndbType
- the database-specific type codeprimaryKey
- whether the column is a primary keylength
- the length of the column (optional)precision
- the precision of the column (optional)required
- whether the column is requiredautoGenerated
- whether the column is auto-generatedgeneratedValueType
- the type of generated value (optional)definition
- the definition of the column (optional)
-
-
Method Details
-
getName
Returns the name of the column.- Returns:
- the name of the column
-
getDataType
Returns the data type of the column.- Returns:
- the data type of the column
-
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
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
Returns the definition of the column, if available.- Returns:
- the definition of the column, or null if not specified
-
getSqlType
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
-