Class AlterColumnNullabilityCommand

  • All Implemented Interfaces:
    AlterTableCommand

    public class AlterColumnNullabilityCommand
    extends Object
    implements AlterTableCommand
    Marks a column as not null or nullable. Make sure that the column being altered to NOT NULL is not used in an index on SQL Server. If it is, drop the index first, alter the column, and recreate the index.
    • Constructor Detail

      • AlterColumnNullabilityCommand

        public AlterColumnNullabilityCommand​(HibernateDatabaseCapabilities databaseCapabilities,
                                             String columnName,
                                             String oldDataType,
                                             NullChoice nullChoice)
        Create an alter column to null/not null action.
        Parameters:
        columnName - The name of the column to alter
        oldDataType - The original data type of the column, required because some DBs don't let you only alter the null/not null property of the column. It is your responsibility to get this right.
        nullChoice - Whether the column should be nullable or not null.
        Since:
        7.20
    • Method Detail

      • getCommandName

        public String getCommandName()
        Specified by:
        getCommandName in interface AlterTableCommand
        Returns:
        The keyword/name of the current command for the current database (e.g. altering a column is "alter column" on PostgreSQL and "modify" on MySQL.
      • getCommandParameters

        public String getCommandParameters()
        Specified by:
        getCommandParameters in interface AlterTableCommand
        Returns:
        The part that comes after the command name. E.g. "colname set not null" which would be after "alter column colname set not null"