mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 17:18:24 +08:00
!184 BaseMapper 添加 selectOneWithRelationsByIdAs 方法
Merge pull request !184 from Jerry_Zheng/main
This commit is contained in:
commit
c4872f913a
@ -500,6 +500,20 @@ public interface BaseMapper<T> {
|
||||
return MapperUtil.queryRelations(this, selectOneById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主表主键来查询 1 条数据。
|
||||
* @param id 表主键
|
||||
* @param asType 接收数据类型
|
||||
* @return 实体类数据
|
||||
*/
|
||||
default <R> R selectOneWithRelationsByIdAs(Serializable id, Class<R> asType) {
|
||||
try {
|
||||
MappedStatementTypes.setCurrentType(asType);
|
||||
return (R) selectOneWithRelationsById(id);
|
||||
} finally {
|
||||
MappedStatementTypes.clear();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 根据查询条件来查询 1 条数据。
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user