mirror of
https://github.com/moparisthebest/JdbcMapper
synced 2024-11-22 00:52:16 -05:00
Rename JdbcMapper.DatabaseType.STANDARD to ANY
This commit is contained in:
parent
5522014f8e
commit
d89078ad89
@ -129,7 +129,7 @@ public interface JdbcMapper extends Closeable {
|
|||||||
public enum DatabaseType {
|
public enum DatabaseType {
|
||||||
DEFAULT(null, null),
|
DEFAULT(null, null),
|
||||||
BIND(null, null),
|
BIND(null, null),
|
||||||
STANDARD("numeric", "text"),
|
ANY("NUMERIC", "TEXT"),
|
||||||
UNNEST("NUMERIC", "VARCHAR"),
|
UNNEST("NUMERIC", "VARCHAR"),
|
||||||
ORACLE("ARRAY_NUM_TYPE", "ARRAY_STR_TYPE"),
|
ORACLE("ARRAY_NUM_TYPE", "ARRAY_STR_TYPE"),
|
||||||
;
|
;
|
||||||
|
@ -126,7 +126,7 @@ public class JdbcMapperProcessor extends AbstractProcessor {
|
|||||||
enumType = types.getDeclaredType(elements.getTypeElement(Enum.class.getCanonicalName()), types.getWildcardType(null, null));
|
enumType = types.getDeclaredType(elements.getTypeElement(Enum.class.getCanonicalName()), types.getWildcardType(null, null));
|
||||||
|
|
||||||
final String databaseType = processingEnv.getOptions().get("jdbcMapper.databaseType");
|
final String databaseType = processingEnv.getOptions().get("jdbcMapper.databaseType");
|
||||||
defaultDatabaseType = databaseType == null || databaseType.isEmpty() ? JdbcMapper.DatabaseType.STANDARD : JdbcMapper.DatabaseType.valueOf(databaseType.toUpperCase());
|
defaultDatabaseType = databaseType == null || databaseType.isEmpty() ? JdbcMapper.DatabaseType.ANY : JdbcMapper.DatabaseType.valueOf(databaseType.toUpperCase());
|
||||||
defaultArrayNumberTypeName = processingEnv.getOptions().get("jdbcMapper.arrayNumberTypeName");
|
defaultArrayNumberTypeName = processingEnv.getOptions().get("jdbcMapper.arrayNumberTypeName");
|
||||||
if (defaultArrayNumberTypeName == null || defaultArrayNumberTypeName.isEmpty())
|
if (defaultArrayNumberTypeName == null || defaultArrayNumberTypeName.isEmpty())
|
||||||
defaultArrayNumberTypeName = defaultDatabaseType.arrayNumberTypeName;
|
defaultArrayNumberTypeName = defaultDatabaseType.arrayNumberTypeName;
|
||||||
@ -188,7 +188,7 @@ public class JdbcMapperProcessor extends AbstractProcessor {
|
|||||||
case ORACLE:
|
case ORACLE:
|
||||||
arrayInList = new OracleArrayInList(arrayNumberTypeName, arrayStringTypeName);
|
arrayInList = new OracleArrayInList(arrayNumberTypeName, arrayStringTypeName);
|
||||||
break;
|
break;
|
||||||
case STANDARD:
|
case ANY:
|
||||||
arrayInList = new ArrayInList(arrayNumberTypeName, arrayStringTypeName);
|
arrayInList = new ArrayInList(arrayNumberTypeName, arrayStringTypeName);
|
||||||
break;
|
break;
|
||||||
case UNNEST:
|
case UNNEST:
|
||||||
@ -411,7 +411,7 @@ public class JdbcMapperProcessor extends AbstractProcessor {
|
|||||||
"(" + inColumnName + " NOT IN(select column_value from table(?)))" :
|
"(" + inColumnName + " NOT IN(select column_value from table(?)))" :
|
||||||
"(" + inColumnName + " IN(select column_value from table(?)))";
|
"(" + inColumnName + " IN(select column_value from table(?)))";
|
||||||
break;
|
break;
|
||||||
case STANDARD:
|
case ANY:
|
||||||
replacement = not ?
|
replacement = not ?
|
||||||
"(" + inColumnName + " != ANY(?))" :
|
"(" + inColumnName + " != ANY(?))" :
|
||||||
"(" + inColumnName + " = ANY(?))";
|
"(" + inColumnName + " = ANY(?))";
|
||||||
@ -790,7 +790,7 @@ public class JdbcMapperProcessor extends AbstractProcessor {
|
|||||||
*/
|
*/
|
||||||
//w.write("(Array) createArray.invoke(conn.unwrap(oracleConnection), \"");
|
//w.write("(Array) createArray.invoke(conn.unwrap(oracleConnection), \"");
|
||||||
break;
|
break;
|
||||||
case STANDARD:
|
case ANY:
|
||||||
case UNNEST:
|
case UNNEST:
|
||||||
w.write("conn.createArrayOf(\"");
|
w.write("conn.createArrayOf(\"");
|
||||||
break;
|
break;
|
||||||
|
@ -71,7 +71,7 @@ public class SimpleSQLChecker implements SQLChecker {
|
|||||||
if (sqlStatement.trim().substring(0, 5).toUpperCase().equals("MERGE"))
|
if (sqlStatement.trim().substring(0, 5).toUpperCase().equals("MERGE"))
|
||||||
return sqlStatement;
|
return sqlStatement;
|
||||||
return "EXPLAIN PLAN FOR " + sqlStatement;
|
return "EXPLAIN PLAN FOR " + sqlStatement;
|
||||||
case STANDARD:
|
case ANY:
|
||||||
return "EXPLAIN " + sqlStatement;
|
return "EXPLAIN " + sqlStatement;
|
||||||
}
|
}
|
||||||
return sqlStatement;
|
return sqlStatement;
|
||||||
|
@ -26,7 +26,7 @@ public class ArrayInList implements InList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayInList() {
|
public ArrayInList() {
|
||||||
this(JdbcMapper.DatabaseType.STANDARD.arrayNumberTypeName, JdbcMapper.DatabaseType.STANDARD.arrayStringTypeName);
|
this(JdbcMapper.DatabaseType.ANY.arrayNumberTypeName, JdbcMapper.DatabaseType.ANY.arrayStringTypeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String columnAppend(final String columnName) {
|
protected String columnAppend(final String columnName) {
|
||||||
|
16
test/pom.xml
16
test/pom.xml
@ -210,5 +210,21 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>any</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<compilerArgs>
|
||||||
|
<compilerArg>-AjdbcMapper.databaseType=ANY</compilerArg>
|
||||||
|
</compilerArgs>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
</project>
|
</project>
|
@ -4,7 +4,6 @@ import com.moparisthebest.jdbc.Cleaner;
|
|||||||
import com.moparisthebest.jdbc.dto.*;
|
import com.moparisthebest.jdbc.dto.*;
|
||||||
import com.moparisthebest.jdbc.util.ResultSetIterable;
|
import com.moparisthebest.jdbc.util.ResultSetIterable;
|
||||||
|
|
||||||
import java.io.Closeable;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Time;
|
import java.sql.Time;
|
||||||
@ -20,7 +19,7 @@ import java.time.*;
|
|||||||
*/
|
*/
|
||||||
@JdbcMapper.Mapper(
|
@JdbcMapper.Mapper(
|
||||||
jndiName = "bob",
|
jndiName = "bob",
|
||||||
databaseType = JdbcMapper.DatabaseType.STANDARD, // todo: PrestoPersonDao breaks with ORACLE or UNNEST
|
databaseType = JdbcMapper.DatabaseType.ANY, // todo: PrestoPersonDao breaks with ORACLE or UNNEST
|
||||||
cachePreparedStatements = JdbcMapper.OptionalBool.FALSE
|
cachePreparedStatements = JdbcMapper.OptionalBool.FALSE
|
||||||
// , sqlParser = SimpleSQLParser.class
|
// , sqlParser = SimpleSQLParser.class
|
||||||
, allowReflection = JdbcMapper.OptionalBool.TRUE
|
, allowReflection = JdbcMapper.OptionalBool.TRUE
|
||||||
|
@ -4,7 +4,6 @@ import com.moparisthebest.jdbc.Cleaner;
|
|||||||
import com.moparisthebest.jdbc.dto.*;
|
import com.moparisthebest.jdbc.dto.*;
|
||||||
import com.moparisthebest.jdbc.util.ResultSetIterable;
|
import com.moparisthebest.jdbc.util.ResultSetIterable;
|
||||||
|
|
||||||
import java.io.Closeable;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Time;
|
import java.sql.Time;
|
||||||
@ -20,7 +19,7 @@ import java.time.*;
|
|||||||
*/
|
*/
|
||||||
@JdbcMapper.Mapper(
|
@JdbcMapper.Mapper(
|
||||||
jndiName = "bob",
|
jndiName = "bob",
|
||||||
databaseType = JdbcMapper.DatabaseType.STANDARD, // PrestoPersonDao breaks with ORACLE or UNNEST
|
databaseType = JdbcMapper.DatabaseType.ANY, // PrestoPersonDao breaks with ORACLE or UNNEST
|
||||||
cachePreparedStatements = JdbcMapper.OptionalBool.FALSE
|
cachePreparedStatements = JdbcMapper.OptionalBool.FALSE
|
||||||
, sqlParser = PrestoSQLParser.class
|
, sqlParser = PrestoSQLParser.class
|
||||||
, allowReflection = JdbcMapper.OptionalBool.TRUE
|
, allowReflection = JdbcMapper.OptionalBool.TRUE
|
||||||
|
Loading…
Reference in New Issue
Block a user