类 TypeNames
- java.lang.Object
-
- org.hibernate.dialect.TypeNames
-
public final class TypeNames extends Object
This class maps a type to names. Associations may be marked with a capacity. Calling the get() method with a type and actual size n will return the associated name with smallest capacity >= n, if available and an unmarked default type otherwise. Eg, settingnames.put( type, "TEXT" ); names.put( type, 255, "VARCHAR($l)" ); names.put( type, 65534, "LONGVARCHAR($l)" );will give you back the following:names.get( type ) // --> "TEXT" (default) names.get( type, 100 ) // --> "VARCHAR(100)" (100 is in [0:255]) names.get( type, 1000 ) // --> "LONGVARCHAR(1000)" (1000 is in [256:65534]) names.get( type, 100000 ) // --> "TEXT" (default)
On the other hand, simply puttingnames.put( type, "VARCHAR($l)" );would result innames.get( type ) // --> "VARCHAR($l)" (will cause trouble) names.get( type, 100 ) // --> "VARCHAR(100)" names.get( type, 10000 ) // --> "VARCHAR(10000)"
- 作者:
- Christoph Beck
-
-
构造器概要
构造器 构造器 说明 TypeNames()
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 booleancontainsTypeName(String typeName)Check whether or not the provided typeName exists.Stringget(int typeCode)get default type name for specified typeStringget(int typeCode, long size, int precision, int scale)get type name for specified type and sizevoidput(int typeCode, long capacity, String value)Register a weighted typeCode mappingvoidput(int typeCode, String value)Register a default (non-weighted) typeCode mapping
-
-
-
方法详细资料
-
get
public String get(int typeCode) throws MappingException
get default type name for specified type- 参数:
typeCode- the type key- 返回:
- the default type name associated with specified key
- 抛出:
MappingException- Indicates that no registrations were made for that typeCode
-
get
public String get(int typeCode, long size, int precision, int scale) throws MappingException
get type name for specified type and size- 参数:
typeCode- the type keysize- the SQL lengthscale- the SQL scaleprecision- the SQL precision- 返回:
- the associated name with smallest capacity >= size, if available and the default type name otherwise
- 抛出:
MappingException- Indicates that no registrations were made for that typeCode
-
put
public void put(int typeCode, long capacity, String value)Register a weighted typeCode mapping- 参数:
typeCode- the JDBC type codecapacity- The capacity for this weightingvalue- The mapping (type name)
-
put
public void put(int typeCode, String value)Register a default (non-weighted) typeCode mapping- 参数:
typeCode- the type keyvalue- The mapping (type name)
-
containsTypeName
public boolean containsTypeName(String typeName)
Check whether or not the provided typeName exists.- 参数:
typeName- the type name.- 返回:
- true if the given string has been registered as a type.
-
-