The type of map
When you prepare a Hibernate mapping file, we've seen you map Java data types to the RDBMS data format. T
he types that have been
declared
used in the mapping file are not Java data types;
This type is called the Hibernate mapping type and can be translated from Java into SQL and vice versa.
In this chapter, you list all the basics, dates and times, large data objects, and other embedded mapping data types.
The original type
The type of map
|
Java type
|
ANSI SQL type
|
integer
|
int or java.lang.Integer
|
INTEGER
|
long
|
long or java.lang.Long
|
BIGINT
|
short
|
short or java.lang.Short
|
SMALLINT
|
float
|
float or java.lang.Float
|
FLOAT
|
double
|
double or java.lang.Double
|
DOUBLE
|
big_decimal
|
java.math.BigDecimal
|
NUMERIC
|
character
|
java.lang.String
|
CHAR(1)
|
string
|
java.lang.String
|
VARCHAR
|
byte
|
byte or java.lang.Byte
|
TINYINT
|
boolean
|
Boolean or java.lang.Boolean
|
BIT
|
yes/no
|
Boolean or java.lang.Boolean
|
CHAR(1) ('Y' or 'N')
|
true/false
|
Boolean or java.lang.Boolean
|
CHAR(1) ('T' or 'F')
|
The date and time type
The type of map
|
Java type
|
ANSI SQL type
|
date
|
java.util.Date or java.sql.Date
|
DATE
|
time
|
java.util.Date or java.sql.Time
|
TIME
|
timestamp
|
java.util.Date or java.sql.Timestamp
|
TIMESTAMP
|
calendar
|
java.util.Calendar
|
TIMESTAMP
|
calendar_date
|
java.util.Calendar
|
DATE
|
Binary and large data objects
The type of map
|
Java type
|
ANSI SQL type
|
binary
|
byte[]
|
VARBINARY (or BLOB)
|
text
|
java.lang.String
|
Clob
|
serializable
|
any Java class that implements java.io.Serializable
|
VARBINARY (or BLOB)
|
Clob
|
java.sql.Clob
|
Clob
|
Blob
|
java.sql.Blob
|
Blob
|
JDK-related type
The type of map
|
Java type
|
ANSI SQL type
|
class
|
java.lang.Class
|
VARCHAR
|
locale
|
java.util.Locale
|
VARCHAR
|
timezone
|
java.util.TimeZone
|
VARCHAR
|
currency
|
java.util.Currency
|
VARCHAR
|