fixed baseMapper.selectOneByQueryAs() method

This commit is contained in:
开源海哥 2023-05-23 16:32:58 +08:00
parent e116568a06
commit 040738a832

View File

@ -331,8 +331,13 @@ public interface BaseMapper<T> {
* @return 数据内容
*/
default <R> R selectOneByQueryAs(QueryWrapper queryWrapper, Class<R> asType) {
List<R> entities = selectListByQueryAs(queryWrapper.limit(1), asType);
return (entities == null || entities.isEmpty()) ? null : entities.get(0);
try {
MappedStatementTypes.setCurrentType(asType);
List<R> entities = selectListByQueryAs(queryWrapper.limit(1), asType);
return (entities == null || entities.isEmpty()) ? null : entities.get(0);
} finally {
MappedStatementTypes.clear();
}
}
/**