When browsing https://mybatis.org/mybatis-3/statement-builders.html, I found a question about the column value type of the oracle database. As shown in the sample code below, if I pass a hashmap, such as Map map = new HashMap<>();the field type of the value value is Object type,which means that mybatis cannot judge the column value type and unified Use String type?

// Builder / Fluent style public String insertPersonSql() { String sql = new SQL() .INSERT_INTO("PERSON") .VALUES("ID, FIRST_NAME", "#{id}, #{firstName}") .VALUES("LAST_NAME", "#{lastName}") .toString(); return sql; }

Because I see the following methods in the abstract class org.apache.ibatis.jdbc.AbstractSQL are treated as the String type uniformly.

public T INTO_VALUES(String... values) { List list = sql().valuesList.get(sql().valuesList.size() - 1); Collections.addAll(list, values); return getSelf(); }

In fact, when I put Map map = new HashMap<>() with a value whose key is "name" and value is "this is name", the sql statement will construct an exception because the value part does not Converted to String, but becomes a type without double quotes.

From the perspective of dba, the processing logic of this code is actually problematic, which will cause the database cpu to perform forced type conversion, which will affect the execution plan of the SQL statement. All column values are unified as String, which is Oracle's VARCAHR.

Looking forward to your reply and discussion. -,-

Comment From: harawata

Hello @killersteps ,

As shown in the sample code you posted, the purpose of SQL is to build a statement with placeholders (e.g. #{id}). See the following doc for example use cases. https://mybatis.org/mybatis-3/java-api.html#Mapper_Annotation_Examples And the test cases in the following directory may show you how it works. https://github.com/mybatis/mybatis-3/tree/master/src/test/java/org/apache/ibatis/submitted/sqlprovider

You can use SQL to build a static statement, but you may have to add single quotes, escape special characters, etc. by yourself.

As stated in the issue template, we use GitHub Issues only to track bugs and feature requests. Please post your next question to the mailing list or Stack Overflow. Thank you!