mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
build: v1.8.5 release (^.^)YYa!!
This commit is contained in:
parent
c3b7337687
commit
3cd4962fdb
@ -21,18 +21,11 @@ import com.mybatisflex.core.field.FieldQueryBuilder;
|
|||||||
import com.mybatisflex.core.mybatis.MappedStatementTypes;
|
import com.mybatisflex.core.mybatis.MappedStatementTypes;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import com.mybatisflex.core.provider.EntitySqlProvider;
|
import com.mybatisflex.core.provider.EntitySqlProvider;
|
||||||
import com.mybatisflex.core.query.CPI;
|
import com.mybatisflex.core.query.*;
|
||||||
import com.mybatisflex.core.query.FunctionQueryColumn;
|
|
||||||
import com.mybatisflex.core.query.QueryColumn;
|
|
||||||
import com.mybatisflex.core.query.QueryCondition;
|
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
|
||||||
import com.mybatisflex.core.row.Row;
|
import com.mybatisflex.core.row.Row;
|
||||||
import com.mybatisflex.core.table.TableInfo;
|
import com.mybatisflex.core.table.TableInfo;
|
||||||
import com.mybatisflex.core.table.TableInfoFactory;
|
import com.mybatisflex.core.table.TableInfoFactory;
|
||||||
import com.mybatisflex.core.util.ClassUtil;
|
import com.mybatisflex.core.util.*;
|
||||||
import com.mybatisflex.core.util.CollectionUtil;
|
|
||||||
import com.mybatisflex.core.util.ConvertUtil;
|
|
||||||
import com.mybatisflex.core.util.MapperUtil;
|
|
||||||
import org.apache.ibatis.annotations.DeleteProvider;
|
import org.apache.ibatis.annotations.DeleteProvider;
|
||||||
import org.apache.ibatis.annotations.InsertProvider;
|
import org.apache.ibatis.annotations.InsertProvider;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
@ -448,8 +441,18 @@ public interface BaseMapper<T> {
|
|||||||
* @return 实体类数据
|
* @return 实体类数据
|
||||||
*/
|
*/
|
||||||
default T selectOneByQuery(QueryWrapper queryWrapper) {
|
default T selectOneByQuery(QueryWrapper queryWrapper) {
|
||||||
|
List<Join> joins = CPI.getJoins(queryWrapper);
|
||||||
|
if (CollectionUtil.isNotEmpty(joins)) {
|
||||||
return MapperUtil.getSelectOneResult(selectListByQuery(queryWrapper));
|
return MapperUtil.getSelectOneResult(selectListByQuery(queryWrapper));
|
||||||
}
|
}
|
||||||
|
Long limitRows = CPI.getLimitRows(queryWrapper);
|
||||||
|
try {
|
||||||
|
queryWrapper.limit(1);
|
||||||
|
return MapperUtil.getSelectOneResult(selectListByQuery(queryWrapper));
|
||||||
|
} finally {
|
||||||
|
CPI.setLimitRows(queryWrapper, limitRows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据查询条件来查询 1 条数据。
|
* 根据查询条件来查询 1 条数据。
|
||||||
@ -459,8 +462,18 @@ public interface BaseMapper<T> {
|
|||||||
* @return 实体类数据
|
* @return 实体类数据
|
||||||
*/
|
*/
|
||||||
default <R> R selectOneByQueryAs(QueryWrapper queryWrapper, Class<R> asType) {
|
default <R> R selectOneByQueryAs(QueryWrapper queryWrapper, Class<R> asType) {
|
||||||
|
List<Join> joins = CPI.getJoins(queryWrapper);
|
||||||
|
if (CollectionUtil.isNotEmpty(joins)) {
|
||||||
return MapperUtil.getSelectOneResult(selectListByQueryAs(queryWrapper, asType));
|
return MapperUtil.getSelectOneResult(selectListByQueryAs(queryWrapper, asType));
|
||||||
}
|
}
|
||||||
|
Long limitRows = CPI.getLimitRows(queryWrapper);
|
||||||
|
try {
|
||||||
|
queryWrapper.limit(1);
|
||||||
|
return MapperUtil.getSelectOneResult(selectListByQueryAs(queryWrapper, asType));
|
||||||
|
} finally {
|
||||||
|
CPI.setLimitRows(queryWrapper, limitRows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据 Map 构建的条件来查询 1 条数据。
|
* 根据 Map 构建的条件来查询 1 条数据。
|
||||||
@ -470,7 +483,7 @@ public interface BaseMapper<T> {
|
|||||||
*/
|
*/
|
||||||
default T selectOneWithRelationsByMap(Map<String, Object> whereConditions) {
|
default T selectOneWithRelationsByMap(Map<String, Object> whereConditions) {
|
||||||
FlexAssert.notEmpty(whereConditions, "whereConditions");
|
FlexAssert.notEmpty(whereConditions, "whereConditions");
|
||||||
return selectOneWithRelationsByQuery(QueryWrapper.create().where(whereConditions).limit(1L));
|
return selectOneWithRelationsByQuery(QueryWrapper.create().where(whereConditions));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -481,7 +494,7 @@ public interface BaseMapper<T> {
|
|||||||
*/
|
*/
|
||||||
default T selectOneWithRelationsByCondition(QueryCondition whereConditions) {
|
default T selectOneWithRelationsByCondition(QueryCondition whereConditions) {
|
||||||
FlexAssert.notNull(whereConditions, "whereConditions");
|
FlexAssert.notNull(whereConditions, "whereConditions");
|
||||||
return selectOneWithRelationsByQuery(QueryWrapper.create().where(whereConditions).limit(1L));
|
return selectOneWithRelationsByQuery(QueryWrapper.create().where(whereConditions));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -491,8 +504,18 @@ public interface BaseMapper<T> {
|
|||||||
* @return 实体类数据
|
* @return 实体类数据
|
||||||
*/
|
*/
|
||||||
default T selectOneWithRelationsByQuery(QueryWrapper queryWrapper) {
|
default T selectOneWithRelationsByQuery(QueryWrapper queryWrapper) {
|
||||||
|
List<Join> joins = CPI.getJoins(queryWrapper);
|
||||||
|
if (CollectionUtil.isNotEmpty(joins)) {
|
||||||
return MapperUtil.queryRelations(this, MapperUtil.getSelectOneResult(selectListByQuery(queryWrapper)));
|
return MapperUtil.queryRelations(this, MapperUtil.getSelectOneResult(selectListByQuery(queryWrapper)));
|
||||||
}
|
}
|
||||||
|
Long limitRows = CPI.getLimitRows(queryWrapper);
|
||||||
|
try {
|
||||||
|
queryWrapper.limit(1);
|
||||||
|
return MapperUtil.queryRelations(this, MapperUtil.getSelectOneResult(selectListByQuery(queryWrapper)));
|
||||||
|
} finally {
|
||||||
|
CPI.setLimitRows(queryWrapper, limitRows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据主表主键来查询 1 条数据。
|
* 根据主表主键来查询 1 条数据。
|
||||||
@ -528,8 +551,18 @@ public interface BaseMapper<T> {
|
|||||||
* @return 实体类数据
|
* @return 实体类数据
|
||||||
*/
|
*/
|
||||||
default <R> R selectOneWithRelationsByQueryAs(QueryWrapper queryWrapper, Class<R> asType) {
|
default <R> R selectOneWithRelationsByQueryAs(QueryWrapper queryWrapper, Class<R> asType) {
|
||||||
|
List<Join> joins = CPI.getJoins(queryWrapper);
|
||||||
|
if (CollectionUtil.isNotEmpty(joins)) {
|
||||||
return MapperUtil.queryRelations(this, MapperUtil.getSelectOneResult(selectListByQueryAs(queryWrapper, asType)));
|
return MapperUtil.queryRelations(this, MapperUtil.getSelectOneResult(selectListByQueryAs(queryWrapper, asType)));
|
||||||
}
|
}
|
||||||
|
Long limitRows = CPI.getLimitRows(queryWrapper);
|
||||||
|
try {
|
||||||
|
queryWrapper.limit(1);
|
||||||
|
return MapperUtil.queryRelations(this, MapperUtil.getSelectOneResult(selectListByQueryAs(queryWrapper, asType)));
|
||||||
|
} finally {
|
||||||
|
CPI.setLimitRows(queryWrapper, limitRows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据多个主键来查询多条数据。
|
* 根据多个主键来查询多条数据。
|
||||||
|
|||||||
@ -55,7 +55,8 @@ class OuterMapperTest {
|
|||||||
INNER.ID,
|
INNER.ID,
|
||||||
INNER.TYPE)
|
INNER.TYPE)
|
||||||
.from(OUTER.as("o"))
|
.from(OUTER.as("o"))
|
||||||
.leftJoin(INNER).as("i").on(INNER.ID.eq(2));
|
.leftJoin(INNER).as("i").on(INNER.ID.eq(2))
|
||||||
|
.limit(1);
|
||||||
Outer outer = outerMapper.selectOneByQuery(queryWrapper);
|
Outer outer = outerMapper.selectOneByQuery(queryWrapper);
|
||||||
System.out.println(outer);
|
System.out.println(outer);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user