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 codes
to instances of theDdlType
interface.- Since:
- 6.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DdlTypeRegistry(TypeConfiguration typeConfiguration)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addDescriptor(int sqlTypeCode, DdlType ddlType)
Add a mapping from the given type code to the givenDdlType
.void
addDescriptor(DdlType ddlType)
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.void
addDescriptorIfAbsent(DdlType ddlType)
DdlType
getDescriptor(int sqlTypeCode)
Returns the registeredDdlType
for the given SQL type code.Integer
getSqlTypeCode(String rawTypeName)
Returns theSqlTypes
type code for the given DDL raw type name, ornull
if the type code cannot be determined from the registrations.String
getTypeName(int typeCode, Long size, Integer precision, Integer scale)
Deprecated.not appropriate for named enum or array types, usegetTypeName(int, Size, Type)
insteadString
getTypeName(int typeCode, Dialect dialect)
Get the SQL type name for the specifiedJDBC type code
, filling in the placemarkers$l
,$p
, and$s
with the default length, precision, and scale for the given SQL dialect.String
getTypeName(int typeCode, Size size)
Deprecated.not appropriate for named enum or array types, usegetTypeName(int, Size, Type)
insteadString
getTypeName(int typeCode, Size columnSize, Type type)
Get the SQL type name for the specifiedJDBC type code
and size, filling in the placemarkers$l
,$p
, and$s
with the length, precision, and scale determined by the given size object.boolean
isTypeNameRegistered(String typeName)
Determines if there is a registeredDdlType
whose 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 theSqlTypes
type code for the given DDL raw type name, ornull
if the type code cannot be determined from the registrations.
-
getDescriptor
public DdlType getDescriptor(int sqlTypeCode)
Returns the registeredDdlType
for the given SQL type code.Note that the "long" types
Types.LONGVARCHAR
,Types.LONGNVARCHAR
, andTypes.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 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$s
with 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
@Deprecated(since="6.3") public String getTypeName(int typeCode, Size size)
Deprecated.not appropriate for named enum or array types, usegetTypeName(int, Size, Type)
insteadGet the SQL type name for the specifiedJDBC 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 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, Size columnSize, Type type)
Get the SQL type name for the specifiedJDBC 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 codecolumnSize
- an object which determines the length, precision, and scaletype
- theType
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, usegetTypeName(int, Size, Type)
insteadGet the SQL type name for the specifiedJDBC 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 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 registeredDdlType
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
-
-