Class QSRTmpl

    • Constructor Detail

      • QSRTmpl

        public QSRTmpl()
    • Method Detail

      • resolve

        @NotNull
        public <T> List<T> resolve​(@NotNull
                                   QueryStructure queryStructure,
                                   @NotNull
                                   QueryPayload payload,
                                   @NotNull
                                   Class<T> clazz)
        将QueryStructure解析至SQL并执行
        Specified by:
        resolve in interface QSR
        Parameters:
        queryStructure - [QueryStructure]
        clazz - QSR模版支持`JavaBean`, `Map`, 以及`Long`, `String`, `Boolean`等基本类型。另外,默认使用的JdbcQSR(为QSR的子类)还额外支持`IResultSetWalker`
        Returns:
        clazz为基本类型时,可能返回List 当动作为insert时,返回值为List<ID>
      • insert

        @NotNull
        public List<Object> insert​(@NotNull
                                   QueryStructure queryStructure,
                                   @NotNull
                                   QueryPayload payload,
                                   @NotNull
                                   Class<?> clazz)
        Description copied from interface: QSR
        将QueryStructure解析至SQL并执行(insert) insert方法和resolve方法的区别是 返回结果不一样
        Specified by:
        insert in interface QSR
        Parameters:
        queryStructure - [QueryStructure]
        clazz - Class<JavaBean>
        Returns:
        List<ID>
      • resolve

        @NotNull
        public <T> List<T> resolve​(@NotNull
                                   HashMapStore configStore,
                                   @NotNull
                                   QueryStructureAction action,
                                   @NotNull
                                   String sql,
                                   @NotNull
                                   Object[] params,
                                   @NotNull
                                   Class<T> clazz)
        执行一个SQL查询
        Specified by:
        resolve in interface QSR
        Parameters:
        sql - 单条sql语句 e.g. SELECT * FROM user WHERE user.id = ?
        params - 参数数组 e.g. [1]
        clazz - `JavaBean`, `Map`, and basic type e.g. `Long`, `String`, `Boolean` etc. for select by default; [Int] for update
        action - [QueryStructureAction]
        Returns:
        clazz为基本类型时,可能返回List
      • execBatch

        @NotNull
        public <T> T execBatch​(@NotNull
                               HashMapStore configStore,
                               @NotNull
                               List<SqlAndParams> sqlAndParamsList,
                               @NotNull
                               Class<T> clazz)
        使用多条语句和参数执行更新,创建,删除等非select语句
        Specified by:
        execBatch in interface QSR
        Parameters:
        clazz - 指定返回结果的类型,支持 List Integer[] Int Boolean(不准确)
        sqlAndParamsList - 多对sql and params
      • insert

        @NotNull
        public <ID,​V,​M extends Map<String,​V>> List<ID> insert​(@NotNull
                                                                                HashMapStore configStore,
                                                                                @NotNull
                                                                                Collection<M> objs,
                                                                                @NotNull
                                                                                String table,
                                                                                @Nullable
                                                                                Class<ID> idColumnClazz)
        动态插入 本实现额外引入了对大数据量数据批量插入的支持 通过 objs 配合数据库表名,动态生成sql语句,并执行
        Specified by:
        insert in interface QSR
        Parameters:
        objs - 需要插入的Map类型的集合
        table - 数据库表名
        idColumnClazz - 如需返回ID,指定ID的类型