`

JPA映射文件jpa.reveng.xml的配置问题

阅读更多

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
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!DOCTYPE hibernate-reverse-engineering   
  3.   SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >  
  4.   
  5. <hibernate-reverse-engineering>  
  6.   
  7.     <type-mapping>  
  8.         <!-- jdbc-type is name fom java.sql.Types -->  
  9.         <sql-type jdbc-type="VARCHAR" length='1' hibernate-type="yes_no"/>  
  10.         <!-- length, scale and precision can be used to specify the mapping precisly -->  
  11.         <sql-type jdbc-type="NUMERIC" precision='1' hibernate-type="boolean"/>  
  12.         <!-- the type-mappings are ordered. This mapping will be consulted last,   
  13.         thus overriden by the previous one if precision=1 for the column -->  
  14.         <sql-type jdbc-type="BIGINT" hibernate-type="java.lang.Long"/>  
  15.         <sql-type jdbc-type="INTEGER" hibernate-type="java.lang.Long"/>  
  16.         <sql-type jdbc-type="NUMERIC" hibernate-type="java.lang.Long"/>  
  17.     </type-mapping>  
  18.   
  19.     <!-- BIN$ is recycle bin tables in Oracle -->  
  20.     <table-filter match-name="BIN$.*" exclude="true"/>  
  21.   
  22.     <!-- Exclude AppFuse tables from all catalogs/schemas -->  
  23.     <!-- 按表名过滤表 -->  
  24.     <table-filter match-name="app_user" exclude="true"/>  
  25.     <table-filter match-name="role" exclude="true"/>  
  26.     <table-filter match-name="user_role" exclude="true"/>  
  27.        
  28. </hibernate-reverse-engineering>  
分享到:
评论
1 楼 aas7612 2011-08-05  
, thanks very much

相关推荐

Global site tag (gtag.js) - Google Analytics