Typeis a strategy for mapping a Java property type to a JDBC type or types. Every persistent attribute of an entity or embeddable object has a
Type, even attributes which represent associations or hold references to embedded objects.
On the other hand, in modern Hibernate,
Type itself is of receding
importance to application developers, though it remains a very important
Basic typesFor basic types, we prefer to model the type mapping in terms the combination of:
JdbcType is able to read and write a single Java type to one, or
sometimes several, JDBC types.
JavaType is able to determine if an attribute of a given Java type is
dirty, and then convert it to one of several other equivalent Java representations
at the request of its partner
For example, if an entity attribute of Java type
BigInteger is mapped to
the JDBC type
VarcharJdbcType will ask its
BigIntegerJavaType to convert instances
BigInteger to and from
String when writing to and reading from
JDBC statements and result sets.
This approach provides quite some flexibility in allowing a given Java type to
map to a range of JDBC types. However, when the built-in conversions don't handle
a particular mapping, a
may assist in the conversion process. For example, a JPA
AttributeConverter might be provided.
JavaType comes with a built-in
MutabilityPlan, but this may be
overridden when types are composed.
org.hibernate.annotations for information on how to influence basic
type mappings using annotations.
Custom typesThe package
org.hibernate.usertypeprovides a way for application developers to define new types without being exposed to the full complexity of the
Typeframework defined in this package.
UserTypemay be used to define single-column type mappings, and thus competes with the "compositional" approach to basic type mappings described above.
- On the other hand, a
CompositeUserTypedefines a way to handle multi-column type mappings, and is a much more flexible form of
Built-in converters for boolean mappingsIn older versions of Hibernate there were dedicated
Types mapping Java
integerdatabase columns. These have now been replaced by the converters:
TrueFalseConverter, which encodes a boolean value as
YesNoConverter, which encodes a boolean value as
NumericBooleanConverter, which encodes a boolean value as
These converters may be applied, as usual, using the JPA-defined
Interface Summary Interface Description AdjustableBasicType<J>Extension contract for
BasicTypeimplementations which understand how to adjust themselves relative to where/how they're used by, for example, accounting for LOB, nationalized, primitive/wrapper, etc.
AssociationTypeA type that represents some kind of association between entities. BasicPluralType<C,E>A basic plural type. BasicType<T>Marker interface for basic types. CompositeTypeRepresents a composite type, a type which itself has typed attributes. ConvertedBasicType<J> ProcedureParameterExtractionAware<T>Optional
Typecontract for implementations that are aware of how to extract values from store procedure OUT/INOUT parameters.
Typecontract for implementations enabled to set store procedure OUT/INOUT parameters values by name.
TypeDefines a mapping between a Java type and one or more JDBC types, as well as describing the in-memory semantics of the given Java type, including: how to compare values and check for "dirtiness", how to clone values, and how to assemble/disassemble values for storage in the second-level cache.
Class Summary Class Description AbstractSingleColumnStandardBasicType<T>TODO : javadoc AbstractStandardBasicType<T>Convenience base class for
AbstractTypeAbstract superclass of the built in Type hierarchy. AnyTypeHandles "any" mappings AnyType.ObjectTypeCacheEntryUsed to externalize discrimination per a given identifier. ArrayTypeA type for persistent arrays. BagType BasicArrayType<T>A type that maps between
BasicCollectionType<C extends Collection<E>,E>A type that maps between
BasicTypeReference<T>A basic type reference. BasicTypeRegistryA registry of
CharBooleanConverter CollectionTypeA type that handles Hibernate
PersistentCollections (including arrays).
ComponentTypeHandles "component" mappings ConvertedBasicArrayType<T>A converted basic array type. ConvertedBasicCollectionType<C extends Collection<E>,E>A converted basic array type. CustomCollectionTypeA custom type for mapping user-written classes that implement
CustomType<J> EmbeddedComponentType EntityTypeBase for types which map associations to persistent entities. EnumType<T extends Enum<T>> Deprecated, for removal: This API element is subject to removal in a future version.Use
IdentifierBagType JavaObjectType ListType ManyToOneTypeA many-to-one association to an entity. MapType MetaType Deprecated, for removal: This API element is subject to removal in a future version. NullType NumericBooleanConverterHandles conversion to/from
OneToOneTypeA one-to-one association to an entity OrderedMapTypeA specialization of the map type, with (resultset-based) ordering. OrderedSetTypeA specialization of the set type, with (resultset-based) ordering. SerializableToBlobType<T extends Serializable> SerializableType<T extends Serializable> SetType SortedMapType SortedSetType SpecialOneToOneTypeA one-to-one association that maps to specific formula(s) instead of the primary key column of the owning entity. SqlTypesDefines a list of constant type codes used to identify generic SQL types. StandardBasicTypesReferences to common
StandardBasicTypeTemplate<J>A BasicType adapter targeting partial portability to 6.0's type system changes. TrueFalseConverterHandles conversion to/from
TypeHelperCertain operations for working with arrays of property values. YesNoConverterHandles conversion to/from
Enum Summary Enum Description ForeignKeyDirectionRepresents directionality of the foreign key constraint WrapperArrayHandlingPossible options for how to handle
Characterbasic mappings encountered in the application domain model.
Exception Summary Exception Description SerializationExceptionThrown when a property cannot be serialized/deserialized