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 mappingJDBC type codesto instances of theDdlTypeinterface.- Since:
- 6.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DdlTypeRegistry(TypeConfiguration typeConfiguration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDescriptor(int sqlTypeCode, DdlType ddlType)Add a mapping from the given type code to the givenDdlType.voidaddDescriptor(DdlType ddlType)voidaddDescriptorIfAbsent(int sqlTypeCode, DdlType ddlType)Add a mapping from the given type code to the givenDdlType, if there is no mapping already present for the given type code.voidaddDescriptorIfAbsent(DdlType ddlType)DdlTypegetDescriptor(int sqlTypeCode)Returns the registeredDdlTypefor the given SQL type code.IntegergetSqlTypeCode(String rawTypeName)Returns theSqlTypestype code for the given DDL raw type name, ornullif the type code cannot be determined from the registrations.StringgetTypeName(int typeCode, Long size, Integer precision, Integer scale)Get the SQL type name for the specifiedJDBC type codeand size, filling in the placemarkers$l,$p, and$swith the given length, precision, and scale.StringgetTypeName(int typeCode, Dialect dialect)Get the SQL type name for the specifiedJDBC type code, filling in the placemarkers$l,$p, and$swith the default length, precision, and scale for the given SQL dialect.StringgetTypeName(int typeCode, Size size)Get the SQL type name for the specifiedJDBC type codeand size, filling in the placemarkers$l,$p, and$swith the length, precision, and scale determined by the given size object.booleanisTypeNameRegistered(String typeName)Determines if there is a registeredDdlTypewhose raw type name matches the given type name, taking into account DDL types registered by Hibernate.
-
-
-
Constructor Detail
-
DdlTypeRegistry
public DdlTypeRegistry(TypeConfiguration typeConfiguration)
-
-
Method Detail
-
addDescriptor
public void addDescriptor(DdlType ddlType)
-
addDescriptor
public void addDescriptor(int sqlTypeCode, DdlType ddlType)Add a mapping from the given type code to the givenDdlType.
-
addDescriptorIfAbsent
public void addDescriptorIfAbsent(DdlType ddlType)
-
addDescriptorIfAbsent
public void addDescriptorIfAbsent(int sqlTypeCode, DdlType ddlType)Add a mapping from the given type code to the givenDdlType, if there is no mapping already present for the given type code.
-
getSqlTypeCode
public Integer getSqlTypeCode(String rawTypeName)
Returns theSqlTypestype code for the given DDL raw type name, ornullif the type code cannot be determined from the registrations.
-
getDescriptor
public DdlType getDescriptor(int sqlTypeCode)
Returns the registeredDdlTypefor the given SQL type code.Note that the "long" types
Types.LONGVARCHAR,Types.LONGNVARCHAR, andTypes.LONGVARBINARYare considered synonyms for their non-LONGcounterparts, with the only difference being that a different default length is used by default:Length.LONGinstead ofLength.DEFAULT.
-
getTypeName
public String getTypeName(int typeCode, Dialect dialect)
Get the SQL type name for the specifiedJDBC type code, filling in the placemarkers$l,$p, and$swith the default length, precision, and scale for the given SQL dialect.- Parameters:
typeCode- the JDBC type codedialect- the dialect which determines the default length, precision, and scale- Returns:
- a SQL column type
-
getTypeName
public String getTypeName(int typeCode, Size size)
Get the SQL type name for the specifiedJDBC type codeand size, filling in the placemarkers$l,$p, and$swith 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 codesize- 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, Long size, Integer precision, Integer scale)
Get the SQL type name for the specifiedJDBC type codeand size, filling in the placemarkers$l,$p, and$swith 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 codesize- the SQL length, if anyprecision- the SQL precision, if anyscale- 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 registeredDdlTypewhose raw type name matches the given type name, taking into account DDL types registered by Hibernate.- Parameters:
typeName- the type name.- Returns:
trueif there is a DDL type with the given raw type name
-
-