/** * A Cursor offers the same results as a List, except it fetches data lazily using an Iterator. * @param <T> the returned cursor element type. * @param statement Unique identifier matching the statement to use. * @return Cursor of mapped objects */ <T> Cursor<T> selectCursor(String statement); /** * A Cursor offers the same results as a List, except it fetches data lazily using an Iterator. * @param <T> the returned cursor element type. * @param statement Unique identifier matching the statement to use. * @param parameter A parameter object to pass to the statement. * @return Cursor of mapped objects */ <T> Cursor<T> selectCursor(String statement, Object parameter); /** * A Cursor offers the same results as a List, except it fetches data lazily using an Iterator. * @param <T> the returned cursor element type. * @param statement Unique identifier matching the statement to use. * @param parameter A parameter object to pass to the statement. * @param rowBounds Bounds to limit object retrieval * @return Cursor of mapped objects */ <T> Cursor<T> selectCursor(String statement, Object parameter, RowBounds rowBounds);
<select id="selectAll" resultType="tk.mybatis.springboot.model.City"> select * from city </select>
Cursor<City> selectAll();
Cursor<City> cityList = sqlSession.selectCursor("selectAll");
Iterator<City> iterator = cityList.iterator();
while(iterator.hasNext()){
City c2 = iterator.next();
Assert.assertNotNull(c2);
Assert.assertNotNull(c2.getName());
Assert.assertNotNull(c2.getState());
}
<select id="selectAll" resultMap="xx.CityMap" resultOrdered="true">
<dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-typehandlers-jsr310</artifactId> <version>1.0.0</version> </dependency>
<typeHandlers> <typeHandler handler="org.apache.ibatis.type.InstantTypeHandler" /> <typeHandler handler="org.apache.ibatis.type.LocalDateTimeTypeHandler" /> <typeHandler handler="org.apache.ibatis.type.LocalDateTypeHandler" /> <typeHandler handler="org.apache.ibatis.type.LocalTimeTypeHandler" /> <typeHandler handler="org.apache.ibatis.type.OffsetDateTimeTypeHandler" /> <typeHandler handler="org.apache.ibatis.type.OffsetTimeTypeHandler" /> <typeHandler handler="org.apache.ibatis.type.ZonedDateTimeTypeHandler" /> </typeHandlers>
<setting name="autoMappingUnknownColumnBehavior" value="WARNING"/>
@SelectProvider(type = UserSqlBuilder.class, method = "buildGetUsersByName")
List<User> getUsersByName(
@Param("name") String name,
@Param("orderByColumn") String orderByColumn); // Multiple arguments
public String buildGetUsersByName(
@Param("name") final String name
@Param("orderByColumn") final String orderByColumn) { // Allow multiple arguments
return new SQL(){{
SELECT("*");
FROM("users");
if (name != null) {
WHERE("name like #{name} || '%'");
}
ORDER_BY(orderByColumn);
}}.toString();
}
public abstract class Entity<K extends Serializable> {
private static final long serialVersionUID = -1L;
protected K id;
public K getId() {
return id;
}
public void setId(K id) {
this.id = id;
}
public class User extends Entity<String>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有