Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2016-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mybatis.dynamic.sql.util.mybatis3;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.ibatis.annotations.SelectProvider;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
/**
* This is a general purpose MyBatis mapper for select statements. It allows you to execute select statements without
* having to write a custom {@link org.apache.ibatis.annotations.ResultMap} for each statement.
*
*
This mapper contains three types of methods:
*
*
The selectOneMappedRow and selectManyMappedRows methods allow you to use select statements with
* any number of columns. MyBatis will process the rows and return a Map of values, or a List of Maps.
*
The selectOne and selectMany methods also allow you to use select statements with any number of columns.
* These methods also allow you to specify a function that will transform a Map of row values into a specific
* object.
*
The other methods are for result sets with a single column. There are functions for many
* data types (Integer, Long, String, etc.) There are also functions that return a single value, and Optional value,
* or a List of values.
*
*
*
This mapper can be injected as-is into a MyBatis configuration, or it can be extended with existing mappers.
*
* @author Jeff Butler
*/
public interface CommonSelectMapper {
/**
* Select a single row as a Map of values. The row may have any number of columns.
* The Map key will be the column name as returned from the
* database (may be aliased if an alias is specified in the select statement). Map entries will be
* of data types determined by the JDBC driver. MyBatis will call ResultSet.getObject() to retrieve
* values from the ResultSet. Reference your JDBC driver documentation to learn about type mappings
* for your specific database.
*
* @param selectStatement the select statement
* @return A Map containing the row values.
*/
@SelectProvider(type = SqlProviderAdapter.class, method = "select")
Map selectOneMappedRow(SelectStatementProvider selectStatement);
/**
* Select a single row of values and then convert the values to a custom type. This is similar
* to the Spring JDBC template method of processing result sets. In this case, MyBatis will first extract
* the row values into a Map, and then a row mapper can retrieve values from the Map and use them
* to construct a custom object.
*
*
See {@link CommonSelectMapper#selectOneMappedRow(SelectStatementProvider)} for details about
* how MyBatis will construct the Map of values.
*
* @param selectStatement the select statement
* @param rowMapper a function that will convert a Map of row values to the desired data type
* @param the datatype of the converted object
* @return the converted object
*/
default R selectOne(SelectStatementProvider selectStatement,
Function