Mapping Types in Hibernate by R4R Team

Generally if we want to make a hibernate mapping Document then we done only one thing that is connectivity between java data types with RDBMS data types. We need to declare and use to all mapping file but we can not say to that those are the java data types they are SQL DATA types. But all done this we called to the hibernate mapping types which can translate java to sql data types.

We have given all basic, date and time, large object, and various other mapping types those are below in the table:

1. Primitive types:

Mapping Types

Java Type

ANSI SQL types

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')


2. Date and time types:

Mapping Types

Java Type

ANSI SQL types

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


3. Binary and large object types:

Mapping Types

Java Type

ANSI SQL types

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


4. JDK-related types:

Mapping Types

Java Type

ANSI SQL types

Class

java.lang.Class

VARCHAR

Locale

java.util.Locale

VARCHAR

Timezone

java.util.TimeZone

VARCHAR

Currency

java.util.Currency

VARCHAR


Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!