cn.schoolwow.quickdao.domain.provider.OracleDatabaseProvider Maven / Gradle / Ivy
package cn.schoolwow.quickdao.domain.provider;
import cn.schoolwow.quickdao.domain.database.parent.DatabaseType;
public class OracleDatabaseProvider implements DatabaseProvider {
@Override
public String name() {
return "oracle";
}
@Override
public DatabaseType getDatabaseType() {
return DatabaseType.Oracle;
}
@Override
public String comment(String comment) {
return "";
}
@Override
public String escape(String value) {
return "\"" + value + "\"";
}
@Override
public boolean returnGeneratedKeys() {
return true;
}
@Override
public String convertJavaTypeToColumnType(String javaType) {
switch (javaType){
case "char":
case "java.lang.Character":{return "CHAR";}
case "short":
case "java.lang.Short":
case "int":
case "java.lang.Integer":{return "INTEGER";}
case "float":
case "java.lang.Float":{return "BINARY_FLOAT";}
case "long":
case "java.lang.Long":{return "INTEGER";}
case "double":
case "java.lang.Double":{return "BINARY_DOUBLE";}
case "java.lang.String":{return "VARCHAR2(255)";}
case "java.util.Date":{return "TIMESTAMP";}
case "java.sql.Date":{return "DATE";}
case "java.sql.Timestamp":{return "TIMESTAMP";}
case "java.time.LocalDate":{return "DATE";}
case "java.time.LocalDateTime":{return "DATETIME";}
case "java.math.BigDecimal":{return "INTEGER";}
case "java.sql.Blob":{return "BLOB";}
case "java.sql.Clob":{return "CLOB";}
case "java.sql.NClob":{return "NCLOB";}
}
throw new IllegalArgumentException("目前不支持转换java数据类型["+javaType+"]为数据库类型");
}
@Override
public String convertColumnTypeToJavaType(String columnType) {
String rawColumnType = columnType;
if(columnType.contains("(")){
columnType = columnType.substring(0, columnType.indexOf("("));
}
columnType = columnType.trim().toUpperCase();
//INT类型
switch (columnType){
case "CHAR":{return "String";}
case "INTEGER":{return "Integer";}
case "BINARY_FLOAT":{return "Float";}
case "VARCHAR2":{return "String";}
case "DATE":{return "java.time.LocalDate";}
case "TIMESTAMP":{return "java.sql.Timestamp";}
}
throw new IllegalArgumentException("目前不支持转换数据库类型["+rawColumnType+"]为java数据类型");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy