Hibernate讲解(三)-Hibernate的基本映射数据类型
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.pojo.Users">
<composite-id>
<key-property name="name" type="string"/>
<key-property name="email" type="string"/>
</composite-id>
<property name="name" length="20"/>
<property name="email"/>
</class>
</hibernate-mapping>
Hibernate映射类型 |
Java类型 |
标准SQL类型 |
integer |
java.lang.Integer |
INTEGER |
long |
java.lang.Long |
BIGINT |
short |
java.lang.Short |
SMALLINT |
float |
java.lang.Float |
FLOAT |
double |
java.lang.Double |
DOUBLE |
big_decimal |
java.math.BigDecimal |
NUMERIC |
character |
java.lang.String |
CHAR(1) |
string |
java.lang.String |
VARCHAR |
byte |
byte或java.lang.Byte |
TINYINT |
boolean |
boolean或java.lang.Boolean |
BIT |
Hibernate映射类型 |
Java类型 |
标准SQL类型 |
yes_no |
boolean或java.lang.Boolean |
CHAR(1)('Y'或'N') |
true_false |
boolean或java.lang.Boolean |
CHAR(1)('Y'或'N') |
date |
java.util.Date或java.sql.Date |
DATE |
time |
java.util.Date或java.sql.Time |
TIME |
timestamp |
java.util.Date或java.sql.Timestamp |
TIMESTAMP |
calendar |
java.util.Calendar |
TIMESTAMP |
calendar_date |
java.util.Calendar |
DATE |
binary |
byte[] |
VARBINARY或BLOB |
text |
java.lang.String |
CLOB |
serializable |
java.io.Serializable实例 |
VARBINARY或BLOB |
clob |
java.sql.Clob |
CLOB |
blob |
java.sql.Blob |
BLOB |
class |
java.lang.Class |
VARCHAR |
locale |
java.util.Locale |
VARCHAR |
timezone |
java.util.TimeZone |
VARCHAR |
currency |
java.util.Currency |
VARCHAR |