JAP映射oracle 表时,因为字段类型是number, 所以生成的对象是BigDECIMAL,如果想类型是:java.util.Long 的话就必须修改配置文件如下:
<sql-type jdbc-type="DECIMAL" hibernate-type="java.lang.Long"></sql-type>
下面是oracle的JDBC-type与数据库字段类型之间的关系。
ARRAY | BLOB | Will be read back as BLOB |
BIGINT | NUMBER(38) | |
BINARY | RAW | Oracle requires the specification of the size for RAW columns. If no size was specified, then 254 is used. Will be read back as VARBINARY |
BIT | NUMBER(1) | Oracle has no native boolean type. |
BLOB | BLOB | |
BOOLEAN | NUMBER(1) | Oracle has no native boolean type. Will be read back as BIT |
CHAR | CHAR | |
CLOB | CLOB | |
DATALINK | BLOB | Will be read back as BLOB |
DATE | DATE | |
DECIMAL | NUMBER | |
DISTINCT | BLOB | Will be read back as BLOB |
DOUBLE | DOUBLE PRECISION | |
FLOAT | FLOAT | Will be read back as DOUBLE |
INTEGER | INTEGER | |
JAVA_OBJECT | BLOB | Will be read back as BLOB |
LONGVARBINARY | BLOB | Will be read back as BLOB |
LONGVARCHAR | CLOB | Will be read back as CLOB |
NULL | BLOB | Will be read back as BLOB |
NUMERIC | NUMBER | Will be read back as DECIMAL |
OTHER | BLOB | Will be read back as BLOB |
REAL | REAL | |
REF | BLOB | Will be read back as BLOB |
SMALLINT | NUMBER(5) | |
STRUCT | BLOB | Will be read back as BLOB |
TIME | DATE | Will be read back as TIMESTAMP |
TIMESTAMP | Oracle8 platform: DATE Oracle9/10 platforms: TIMESTAMP | The TIMESTAMP native type is only supported in Oracle 9 and above. |
TINYINT | NUMBER(3) | |
VARBINARY | RAW | Oracle requires the specification of the size for RAW columns. If no size was specified, then 254 is |
ARRAY | BLOB | Will be read back as BLOB |
BIGINT | NUMBER(38) | |
BINARY | RAW | Oracle requires the specification of the size for RAW columns. If no size was specified, then 254 is used. Will be read back as VARBINARY |
BIT | NUMBER(1) | Oracle has no native boolean type. |
BLOB | BLOB | |
BOOLEAN | NUMBER(1) | Oracle has no native boolean type. Will be read back as BIT |
CHAR | CHAR | |
CLOB | CLOB | |
DATALINK | BLOB | Will be read back as BLOB |
DATE | DATE | |
DECIMAL | NUMBER | |
DISTINCT | BLOB | Will be read back as BLOB |
DOUBLE | DOUBLE PRECISION | |
FLOAT | FLOAT | Will be read back as DOUBLE |
INTEGER | INTEGER | |
JAVA_OBJECT | BLOB | Will be read back as BLOB |
LONGVARBINARY | BLOB | Will be read back as BLOB |
LONGVARCHAR | CLOB | Will be read back as CLOB |
NULL | BLOB | Will be read back as BLOB |
NUMERIC | NUMBER | Will be read back as DECIMAL |
OTHER | BLOB | Will be read back as BLOB |
REAL | REAL | |
REF | BLOB | Will be read back as BLOB |
SMALLINT | NUMBER(5) | |
STRUCT | BLOB | Will be read back as BLOB |
TIME | DATE | Will be read back as TIMESTAMP |
TIMESTAMP | Oracle8 platform: DATE Oracle9/10 platforms: TIMESTAMP | The TIMESTAMP native type is only supported in Oracle 9 and above. |
TINYINT | NUMBER(3) | |
VARBINARY | RAW | Oracle requires the specification of the size for RAW columns. If no size was specified, then 254 is |
ARRAY | BLOB | Will be read back as BLOB |
BIGINT | NUMBER(38) | |
BINARY | RAW | Oracle requires the specification of the size for RAW columns. If no size was specified, then 254 is used. Will be read back as VARBINARY |
BIT | NUMBER(1) | Oracle has no native boolean type. |
BLOB | BLOB | |
BOOLEAN | NUMBER(1) | Oracle has no native boolean type. Will be read back as BIT |
CHAR | CHAR | |
CLOB | CLOB | |
DATALINK | BLOB | Will be read back as BLOB |
DATE | DATE | |
DECIMAL | NUMBER | |
DISTINCT | BLOB | Will be read back as BLOB |
DOUBLE | DOUBLE PRECISION | |
FLOAT | FLOAT | Will be read back as DOUBLE |
INTEGER | INTEGER | |
JAVA_OBJECT | BLOB | Will be read back as BLOB |
LONGVARBINARY | BLOB | Will be read back as BLOB |
LONGVARCHAR | CLOB | Will be read back as CLOB |
NULL | BLOB | Will be read back as BLOB |
NUMERIC | NUMBER | Will be read back as DECIMAL |
OTHER | BLOB | Will be read back as BLOB |
REAL | REAL | |
REF | BLOB | Will be read back as BLOB |
SMALLINT | NUMBER(5) | |
STRUCT | BLOB | Will be read back as BLOB |
TIME | DATE | Will be read back as TIMESTAMP |
TIMESTAMP | Oracle8 platform: DATE Oracle9/10 platforms: TIMESTAMP | The TIMESTAMP native type is only supported in Oracle 9 and above. |
TINYINT | NUMBER(3) | |
VARBINARY | RAW | Oracle requires the specification of the size for RAW columns. If no size was specified, then 254 is |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE hibernate-reverse-engineering
- SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
- <hibernate-reverse-engineering>
- <type-mapping>
- <!-- jdbc-type is name fom java.sql.Types -->
- <sql-type jdbc-type="VARCHAR" length='1' hibernate-type="yes_no"/>
- <!-- length, scale and precision can be used to specify the mapping precisly -->
- <sql-type jdbc-type="NUMERIC" precision='1' hibernate-type="boolean"/>
- <!-- the type-mappings are ordered. This mapping will be consulted last,
- thus overriden by the previous one if precision=1 for the column -->
- <sql-type jdbc-type="BIGINT" hibernate-type="java.lang.Long"/>
- <sql-type jdbc-type="INTEGER" hibernate-type="java.lang.Long"/>
- <sql-type jdbc-type="NUMERIC" hibernate-type="java.lang.Long"/>
- </type-mapping>
- <!-- BIN$ is recycle bin tables in Oracle -->
- <table-filter match-name="BIN$.*" exclude="true"/>
- <!-- Exclude AppFuse tables from all catalogs/schemas -->
- <!-- 按表名过滤表 -->
- <table-filter match-name="app_user" exclude="true"/>
- <table-filter match-name="role" exclude="true"/>
- <table-filter match-name="user_role" exclude="true"/>
- </hibernate-reverse-engineering>