Class DdlTypeRegistry

java.lang.Object
org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry
All Implemented Interfaces:
Serializable

public class DdlTypeRegistry extends Object implements Serializable
A registry mapping JDBC type codes to instances of the DdlType interface.
Since:
6.0
See Also:
  • Constructor Details

  • Method Details

    • addDescriptor

      public void addDescriptor(DdlType ddlType)
      Add a mapping from the type code of the given DdlType to the given DdlType.
    • addDescriptor

      public void addDescriptor(int sqlTypeCode, DdlType ddlType)
      Add a mapping from the given type code to the given DdlType.
    • addDescriptorIfAbsent

      public void addDescriptorIfAbsent(DdlType ddlType)
      Add a mapping from the type code of the given DdlType to the given DdlType, if there is no mapping already present for that type code.
    • addDescriptorIfAbsent

      public void addDescriptorIfAbsent(int sqlTypeCode, DdlType ddlType)
      Add a mapping from the given type code to the given DdlType, if there is no mapping already present for the given type code.
    • getSqlTypeCode

      public Integer getSqlTypeCode(String rawTypeName)
      Returns the SqlTypes type code for the given DDL raw type name, or null if the type code cannot be determined from the registrations.
    • getDescriptor

      public DdlType getDescriptor(int sqlTypeCode)
      Returns the registered DdlType for the given SQL type code.

      Note that the "long" types Types.LONGVARCHAR, Types.LONGNVARCHAR, and Types.LONGVARBINARY are considered synonyms for their non-LONG counterparts, with the only difference being that a different default length is used by default: Length.LONG instead of Length.DEFAULT.

    • getTypeName

      public String getTypeName(int typeCode, Dialect dialect)
      Get the SQL type name for the specified JDBC type code, filling in the placemarkers $l, $p, and $s with the default length, precision, and scale for the given SQL dialect.
      Parameters:
      typeCode - the JDBC type code
      dialect - the dialect which determines the default length, precision, and scale
      Returns:
      a SQL column type
    • getTypeName

      @Deprecated(since="6.3") public String getTypeName(int typeCode, Size size)
      Deprecated.
      not appropriate for named enum or array types, use getTypeName(int, Size, Type) instead
      Get the SQL type name for the specified JDBC type code and size, filling in the placemarkers $l, $p, and $s with the length, precision, and scale determined by the given size object. The returned type name should be of a SQL type large enough to accommodate values of the specified size.
      Parameters:
      typeCode - the JDBC type code
      size - an object which determines the length, precision, and scale
      Returns:
      the associated type name with the smallest capacity that accommodates the given size, if available, and the default type name otherwise
    • getTypeName

      public String getTypeName(int typeCode, Size columnSize, Type type)
      Get the SQL type name for the specified JDBC type code and size, filling in the placemarkers $l, $p, and $s with the length, precision, and scale determined by the given size object. The returned type name should be of a SQL type large enough to accommodate values of the specified size.
      Parameters:
      typeCode - the JDBC type code
      columnSize - an object which determines the length, precision, and scale
      type - the Type mapped to the column
      Returns:
      the associated type name with the smallest capacity that accommodates the given size, if available, and the default type name otherwise
      Since:
      6.3
    • getTypeName

      @Deprecated(since="6.3") public String getTypeName(int typeCode, Long size, Integer precision, Integer scale)
      Deprecated.
      not appropriate for named enum or array types, use getTypeName(int, Size, Type) instead
      Get the SQL type name for the specified JDBC type code and size, filling in the placemarkers $l, $p, and $s with the given length, precision, and scale. The returned type name should be of a SQL type large enough to accommodate values of the specified size.
      Parameters:
      typeCode - the JDBC type code
      size - the SQL length, if any
      precision - the SQL precision, if any
      scale - the SQL scale, if any
      Returns:
      the associated type name with the smallest capacity that accommodates the given size, if available, and the default type name otherwise
    • isTypeNameRegistered

      public boolean isTypeNameRegistered(String typeName)
      Determines if there is a registered DdlType whose raw type name matches the given type name, taking into account DDL types registered by Hibernate.
      Parameters:
      typeName - the type name.
      Returns:
      true if there is a DDL type with the given raw type name