org.hibernate.type
Class TypeResolver

java.lang.Object
  extended by org.hibernate.type.TypeResolver
All Implemented Interfaces:
Serializable

public class TypeResolver
extends Object
implements Serializable

Acts as the contract for getting types and as the mediator between BasicTypeRegistry and TypeFactory.

See Also:
Serialized Form

Constructor Summary
TypeResolver()
           
TypeResolver(BasicTypeRegistry basicTypeRegistry, TypeFactory typeFactory)
           
 
Method Summary
 BasicType basic(String name)
          Locate a Hibernate basic type given (one of) its registration names.
 TypeFactory getTypeFactory()
           
 Type heuristicType(String typeName)
          See heuristicType(String, Properties)
 Type heuristicType(String typeName, Properties parameters)
          Uses heuristics to deduce the proper Type given a string naming the type or Java class.
 void registerTypeOverride(BasicType type)
           
 void registerTypeOverride(CompositeUserType type, String[] keys)
           
 void registerTypeOverride(UserType type, String[] keys)
           
 TypeResolver scope(SessionFactoryImplementor factory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeResolver

public TypeResolver()

TypeResolver

public TypeResolver(BasicTypeRegistry basicTypeRegistry,
                    TypeFactory typeFactory)
Method Detail

scope

public TypeResolver scope(SessionFactoryImplementor factory)

registerTypeOverride

public void registerTypeOverride(BasicType type)

registerTypeOverride

public void registerTypeOverride(UserType type,
                                 String[] keys)

registerTypeOverride

public void registerTypeOverride(CompositeUserType type,
                                 String[] keys)

getTypeFactory

public TypeFactory getTypeFactory()

basic

public BasicType basic(String name)
Locate a Hibernate basic type given (one of) its registration names.

Parameters:
name - The registration name
Returns:
The registered type

heuristicType

public Type heuristicType(String typeName)
                   throws MappingException
See heuristicType(String, Properties)

Parameters:
typeName - The name (see heuristic algorithm discussion on heuristicType(String, Properties)).
Returns:
The deduced type; may be null.
Throws:
MappingException - Can be thrown from heuristicType(String, Properties)

heuristicType

public Type heuristicType(String typeName,
                          Properties parameters)
                   throws MappingException
Uses heuristics to deduce the proper Type given a string naming the type or Java class.

The search goes as follows:

  1. search for a basic type with 'typeName' as a registration key
  2. look for 'typeName' as a class name and
    1. if it names a Type implementor, return an instance
    2. if it names a CompositeUserType or a UserType, return an instance of class wrapped intot the appropriate Type adapter
    3. if it implements Lifecycle, return the corresponding entity type
    4. if it implements Serializable, return the corresponding serializable type

Parameters:
typeName - The name (see heuristic algorithm above).
parameters - Any parameters for the type. Only applied if built!
Returns:
The deduced type; may be null.
Throws:
MappingException - Indicates a problem attempting to resolve 'typeName' as a Class


Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.