Oralce 数据库映射注意事项:
1. 如果数据库中的类型为 char(1), 则映射为 character 或 char
// SQL
PUBLISHED char(1)
// POJO java
char published;
// mapping
<property name="published" type="character">
<column name="PUBLISHED" length="1" />
</property>
若映射成了 string 的话,在数据类型校验时会出错:
// POJO java
String published;
// mapping
<property name="published" type="string">
<column name="PUBLISHED" length="1" />
</property>
类似的错误输出为:
Wrong column type: PUBLISHED, expected: varchar2(1 char)
at org.hibernate.mapping.Table.validateColumns(Table.java:261)
2. 如果为 varchar2(1), 则映射为 string
// SQL
INCLUDES_SS_LIB varchar2(1)
// POJO java
String includedSsLib;
// mapping
<property name="includesSsLib" type="string">
<column name="INCLUDES_SS_LIB" length="1" />
</property>
若映射成了 character 的话,在数据类型校验时会出错:
// POJO java
char includedSsLib;
// mapping
<property name="includesSsLib" type="character">
<column name="INCLUDES_SS_LIB" length="1" />
</property>
类似的错误输出为:
Wrong column type: CHECKED, expected: char(1 char)
at org.hibernate.mapping.Table.validateColumns(Table.java:261)