2017-08-16 188 views
0

我開始使用的MyBatis有註釋,我試圖在這樣的映射器通過一個完整的查詢:傳遞一個完整的SQL查詢作爲參數傳入一個映射器中的MyBatis

public interface Mapper { 

    @Select("#{sql}") 
    public HashMap<String,String> getResult(String sql);  

} 

這是怎麼了我調用方法:

String sql = "select * from table"; 
List<Object> list = session.selectList("getResult",sql); 

當我執行我得到這個例外的程序:

org.apache.ibatis.exceptions.PersistenceException: 
Error querying database. Cause: org.apache.ibatis.type.TypeException: Error setting null for parameter #1 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: Invalid column type: 1111 
+0

每個現代框架的主要目標是阻止sql注入。我會非常驚訝,如果Yoy將有效果 –

回答