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
// 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
public T INTO_VALUES(String... values) {
List
In fact, when I put Map
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!