下面列出了怎么用org.hibernate.type.TypeResolver的API类实例代码及写法,或者点击链接到github查看源代码。
private void resolveLob(final SingularAttributeSourceBasic attributeSource, SimpleValue value) {
// Resolves whether the property is LOB based on the type attribute on the attribute property source.
// Essentially this expects the type to map to a CLOB/NCLOB/BLOB sql type internally and compares.
if ( !value.isLob() && value.getTypeName() != null ) {
final TypeResolver typeResolver = attributeSource.getBuildingContext().getMetadataCollector().getTypeResolver();
final BasicType basicType = typeResolver.basic( value.getTypeName() );
if ( basicType instanceof AbstractSingleColumnStandardBasicType ) {
if ( isLob( ( (AbstractSingleColumnStandardBasicType) basicType ).getSqlTypeDescriptor().getSqlType(), null ) ) {
value.makeLob();
}
}
}
// If the prior check didn't set the lob flag, this will inspect the column sql-type attribute value and
// if this maps to CLOB/NCLOB/BLOB then the value will be marked as lob.
if ( !value.isLob() ) {
for ( RelationalValueSource relationalValueSource : attributeSource.getRelationalValueSources() ) {
if ( ColumnSource.class.isInstance( relationalValueSource ) ) {
if ( isLob( null, ( (ColumnSource) relationalValueSource ).getSqlType() ) ) {
value.makeLob();
}
}
}
}
}
/**
* @deprecated Use {{@link IdsClauseBuilder#IdsClauseBuilder(Dialect, Type, TypeConfiguration, String[], List)}} instead.
*/
@Deprecated
protected IdsClauseBuilder(
Dialect dialect,
Type identifierType,
TypeResolver typeResolver,
String[] columns,
List<Object[]> ids) {
this.dialect = dialect;
this.identifierType = identifierType;
this.typeResolver = typeResolver;
this.columns = columns;
this.ids = ids;
}
public TypeConfiguration() {
this.scope = new Scope();
this.javaTypeDescriptorRegistry = new JavaTypeDescriptorRegistry( this );
this.sqlTypeDescriptorRegistry = new SqlTypeDescriptorRegistry( this );
this.basicTypeRegistry = new BasicTypeRegistry();
this.typeFactory = new TypeFactory( this );
this.typeResolver = new TypeResolver( this, typeFactory );
TypeConfigurationRegistry.INSTANCE.registerTypeConfiguration( this );
}
public void setParameterValues(Properties parameters) {
@SuppressWarnings("unchecked")
final AbstractSingleColumnStandardBasicType<? extends Object> heuristicType = (AbstractSingleColumnStandardBasicType<? extends Object>) new TypeResolver().heuristicType(identifierType.getName(), parameters);
if (heuristicType == null) {
throw new HibernateException("Unsupported identifier type " + identifierType.getName());
}
type = heuristicType;
sqlTypes = new int[]{ type.sqlType() };
}
public TypeLocatorImpl(TypeResolver typeResolver) {
this.typeResolver = typeResolver;
}
public InlineIdsInClauseBuilder(
Dialect dialect, Type identifierType, TypeResolver typeResolver, String[] columns, List<Object[]> ids) {
super( dialect, identifierType, typeResolver, columns, ids );
this.chunkLimit = dialect.getInExpressionCountLimit();
}
public InlineIdsOrClauseBuilder(
Dialect dialect, Type identifierType, TypeResolver typeResolver, String[] columns, List<Object[]> ids) {
super( dialect, identifierType, typeResolver, columns, ids );
}
public InlineIdsSubSelectValuesListBuilder(
Dialect dialect, Type identifierType, TypeResolver typeResolver, String[] columns, List<Object[]> ids) {
super( dialect, identifierType, typeResolver, columns, ids );
}
@Deprecated
protected TypeResolver getTypeResolver(SessionFactory sessionFactory) {
return ((SessionFactoryImplementor) sessionFactory).getTypeResolver();
}
public TypeResolver getTypeResolver() {
return sessionFactoryImplementor.getTypeResolver();
}
/**
* Retrieve the {@link Type} resolver associated with this factory.
*
* @return The type resolver
*
* @deprecated (since 5.2) No replacement, access to and handling of Types will be much different in 6.0
*/
@Deprecated
TypeResolver getTypeResolver();
/**
* Retrieve the {@link Type} resolver associated with this factory.
*
* @return The type resolver
*
* @deprecated (since 5.3) No replacement, access to and handling of Types will be much different in 6.0
*/
@Deprecated
public TypeResolver getTypeResolver() {
return delegate.getTypeResolver();
}
/**
* Retrieve the {@link Type} resolver associated with this factory.
*
* @return The type resolver
*
* @deprecated (since 5.3) No replacement, access to and handling of Types will be much different in 6.0
*/
@Deprecated
public TypeResolver getTypeResolver() {
return metamodel.getTypeConfiguration().getTypeResolver();
}
/**
* Retrieve the {@link Type} resolver associated with this factory.
*
* @return The type resolver
*
* @deprecated (since 5.3) No replacement, access to and handling of Types will be much different in 6.0
*/
@Deprecated
TypeResolver getTypeResolver();
/**
* Retrieve the {@link Type} resolver associated with this factory.
*
* @return The type resolver
*
* @deprecated (since 5.3) No replacement, access to and handling of Types will be much different in 6.0
*/
@Deprecated
public TypeResolver getTypeResolver() {
return delegate.getTypeResolver();
}
/**
* Retrieve the {@link Type} resolver associated with this factory.
*
* @return The type resolver
*
* @deprecated (since 5.3) No replacement, access to and handling of Types will be much different in 6.0
*/
@Deprecated
public TypeResolver getTypeResolver() {
return bootstrapContext.getTypeConfiguration().getTypeResolver();
}
/**
* Retrieve the {@link Type} resolver associated with this factory.
*
* @return The type resolver
*
* @deprecated (since 5.3) No replacement, access to and handling of Types will be much different in 6.0
*/
@Deprecated
public TypeResolver getTypeResolver() {
return bootstrapContext.getTypeConfiguration().getTypeResolver();
}
/**
* Retrieve the {@link Type} resolver associated with this factory.
*
* @return The type resolver
*
* @deprecated (since 5.3) No replacement, access to and handling of Types will be much different in 6.0
*/
@Deprecated
public TypeResolver getTypeResolver() {
return typeResolver;
}
/**
* Temporarily needed to support deprecations
*
* Retrieve the {@link Type} resolver associated with this factory.
*
* @return The type resolver
*
* @deprecated (since 5.3) No replacement, access to and handling of Types will be much different in 6.0
*/
@Deprecated
public TypeResolver getTypeResolver(){
return typeResolver;
}
protected abstract TypeResolver getTypeResolver(SessionFactory sessionFactory);