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.paginate.Page;
|
||||
import com.mybatisflex.core.provider.EntitySqlProvider;
|
||||
import com.mybatisflex.core.query.CPI;
|
||||
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.query.*;
|
||||
import com.mybatisflex.core.row.Row;
|
||||
import com.mybatisflex.core.table.TableInfo;
|
||||
import com.mybatisflex.core.table.TableInfoFactory;
|
||||
import com.mybatisflex.core.util.ClassUtil;
|
||||
import com.mybatisflex.core.util.CollectionUtil;
|
||||
import com.mybatisflex.core.util.ConvertUtil;
|
||||
import com.mybatisflex.core.util.MapperUtil;
|
||||
import com.mybatisflex.core.util.*;
|
||||
import org.apache.ibatis.annotations.DeleteProvider;
|
||||
import org.apache.ibatis.annotations.InsertProvider;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@ -448,7 +441,17 @@ public interface BaseMapper<T> {
|
||||
* @return 实体类数据
|
||||
*/
|
||||
default T selectOneByQuery(QueryWrapper queryWrapper) {
|
||||
return MapperUtil.getSelectOneResult(selectListByQuery(queryWrapper));
|
||||
List<Join> joins = CPI.getJoins(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(joins)) {
|
||||
return MapperUtil.getSelectOneResult(selectListByQuery(queryWrapper));
|
||||
}
|
||||
Long limitRows = CPI.getLimitRows(queryWrapper);
|
||||
try {
|
||||
queryWrapper.limit(1);
|
||||
return MapperUtil.getSelectOneResult(selectListByQuery(queryWrapper));
|
||||
} finally {
|
||||
CPI.setLimitRows(queryWrapper, limitRows);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -459,7 +462,17 @@ public interface BaseMapper<T> {
|
||||
* @return 实体类数据
|
||||
*/
|
||||
default <R> R selectOneByQueryAs(QueryWrapper queryWrapper, Class<R> asType) {
|
||||
return MapperUtil.getSelectOneResult(selectListByQueryAs(queryWrapper, asType));
|
||||
List<Join> joins = CPI.getJoins(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(joins)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -470,7 +483,7 @@ public interface BaseMapper<T> {
|
||||
*/
|
||||
default T selectOneWithRelationsByMap(Map<String, Object> 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) {
|
||||
FlexAssert.notNull(whereConditions, "whereConditions");
|
||||
return selectOneWithRelationsByQuery(QueryWrapper.create().where(whereConditions).limit(1L));
|
||||
return selectOneWithRelationsByQuery(QueryWrapper.create().where(whereConditions));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -491,7 +504,17 @@ public interface BaseMapper<T> {
|
||||
* @return 实体类数据
|
||||
*/
|
||||
default T selectOneWithRelationsByQuery(QueryWrapper queryWrapper) {
|
||||
return MapperUtil.queryRelations(this, MapperUtil.getSelectOneResult(selectListByQuery(queryWrapper)));
|
||||
List<Join> joins = CPI.getJoins(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(joins)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -528,7 +551,17 @@ public interface BaseMapper<T> {
|
||||
* @return 实体类数据
|
||||
*/
|
||||
default <R> R selectOneWithRelationsByQueryAs(QueryWrapper queryWrapper, Class<R> asType) {
|
||||
return MapperUtil.queryRelations(this, MapperUtil.getSelectOneResult(selectListByQueryAs(queryWrapper, asType)));
|
||||
List<Join> joins = CPI.getJoins(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(joins)) {
|
||||
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.TYPE)
|
||||
.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);
|
||||
System.out.println(outer);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user