A.5 All Types

     

The following table shows each of the type classes in the net.sf.hibernate.types package, along with the type name you would use for it in a mapping document, the SQL type used in columns storing mapped values, and any relevant comments about its purpose. In many cases, more detailed discussion can be found earlier. To save space, the ' Type ' which appears at the end of each class name has been removed, except in the case of the Type interface implemented by all the others.

Type class Type name SQL type Notes
Abstract-Component N/A N/A Abstract ancestor of Component , DynaBean , and Object types
Abstract N/A N/A Abstract skeleton used by the built-in types
Array N/A N/A Maps a Java array as a Persistent-Collection
Association N/A N/A Interface used by all associations between entities
Bag N/A N/A Maps collections with bag semantics
BigDecimal big_decimal NUMERIC In Oracle, SQL type is NUMBER
Binary binary VARBINARY Basic type for byte arrays
Blob blob BLOB Not all drivers support this
Boolean boolean BIT A basic type
Byte byte TINYINT A basic type
CalendarDate calendar_date DATE A basic type
Calendar calendar TIMESTAMP A basic type
CharBoolean N/A CHAR Abstract skeleton used to implement yes_no and true_false types
Character character CHAR A basic and primitive type
Class class VARCHAR or VARCHAR2 Basic type that stores a class' name
Clob clob CLOB Not all drivers support this
Component N/A N/A Maps the properties of a contained value class on to a group of columns
Composite-Custom N/A N/A Adapts CompositeUserType implementations to the Type interface
Currency currency VARCHAR or VARCHAR2 Stores ISO code for a currency
Custom N/A N/A Adapts UserType implementations to the Type interface
Date date DATE A basic type
Discriminator N/A N/A Marker interface for types that can be used for discriminator properties (to select the right mapped subclass)
Double double DOUBLE A basic and primitive type
DynaBean N/A N/A Maps Jakarta Commons DynaBeans
Entity N/A N/A Represents a reference to another entity
Float float FLOAT A basic and primitive type
IdentifierBag N/A N/A Supports experimental idbag , mapping a Collection with bag semantics
Identifier N/A N/A Marker interface for types that store identifiers of entities
Immutable N/A N/A Abstract superclass for immutable types; extends NullableType
Integer integer INTEGER A basic and primitive type
List N/A N/A Maps a Java List
Literal N/A N/A Marker interface for types that store SQL literals
Locale locale VARCHAR or VARCHAR2 Stores ISO code for a locale
Long long LONG A basic and primitive type
ManyToOne N/A N/A An association between entities
Map N/A N/A Maps a Java Map
Mutable N/A N/A Abstract superclass for mutable types
Nullable N/A N/A Abstract superclass for simple, one column types that can be null
Object N/A N/A Handles 'any' type mappings
OneToOne N/A N/A An association between entities
Persistent-Collection N/A N/A Supports persistence of collections and arrays
PersistentEnum N/A N/A Maps persistent enumerations
Primitive N/A N/A Abstract skeleton for mapping primitive Java types; extends ImmutableType
Serializable serializable Binary, depends on SQL dialect Catch-all mapping for serializable classes with no better alternative
Set N/A N/A Maps a Java Set
Short short SMALLINT A basic and primitive type
SortedMap N/A N/A Sorted extension of MapType
SortedSet N/A N/A Sorted extension of SetType
String string VARCHAR or VARCHAR2 A basic and primitive type
Time time TIME A basic type
TimeZone timezone VARCHAR or VARCHAR2 Stores time zone ID
Timestamp timestamp TIMESTAMP A basic type
TrueFalse true_false CHAR Stores Booleans as 'T' or 'F'
Type N/A N/A Superinterface of all these types
Version N/A N/A Extends Type for version stamping
YesNo yes_no CHAR Stores Booleans as 'Y' or 'N'

There is also a TypeFactory class which provides assistance in building the right Type implementation for a given need, such as when parsing a type name in a mapping document. Reading its source is interesting.



Hibernate. A Developer's Notebook
Hibernate: A Developers Notebook
ISBN: 0596006969
EAN: 2147483647
Year: 2003
Pages: 65
Authors: James Elliott

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net