The environment uses mybatis plus, the paging plug-in: PageHelper 5.2.0, and the database uses sqlserver2012 or above
In fact, the paging plug-in is ultimately handled by the mybatis interceptor, so it is equivalent to the mybatis environment.
Using paging
PageHelper.startPage(1,10); // Pagination
orderMapper.list(); // Follow the execution
Then an error will be reported
SQL: SELECT id,product_name,xxxx,xxxxx FROM product_xxxx OFFSET ?ROWS FETCH NEXT ?ROWS ONLY
### Cause: com.microsoft.sqlserver.jdbc.SQLServerException: “@P0”There is a grammatical error nearby.
; uncategorized SQLException; SQL state [S0001]; error code [102]; There is a syntax error near "@P0". ; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: There is a syntax error near "@P0".
Finally, after checking, it is found that the paging syntax offset and fetch used by PageHelper are sqlserver’s support for sorting.
Therefore, if you want to use this plug-in to page, you need to add sorting.
PageHelper.startPage(1,10,"xxxx sorted table field name, not attribute name");
orderMapper.list(); // Follow the execution
Or use the default sort field
PageHelper.startPage(1,10,"CURRENT_TIMESTAMP");
orderMapper.list(); //Follow up
Read More:
- Mybatis plus paging Plugin and Auto-fill
- How to Solve mybatis-plus Paging Plug-in PaginationInnerInterceptor error
- springboot sqlserver druid reward: validateConnection false
- [Solved] Mybatis.generator error: Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.2
- [Solved] spring boot integrated PageHelper Error
- [Solved] PageHelper Error: syntax error, error in :‘it 1 LIMIT ? ‘
- [Solved] Mybatis Error: Could not find resource mybatis-conf.xml
- [Solved] mybatis plus Insert Error: mybatis plus Error setting null for parameter #1 with JdbcType OTHER
- [Solved] Tk-Mybatis Error: tk.mybatis.mapper.MapperException:
- How to Solve PageHelper.startPage count Error
- [Solved] Spring integrates canal to call feign error: pool-1-thread-1
- Springboot integrates Redis annotation and access error: java.io.NotSerializableException: com.demo.entity.MemberEntity
- Mybatisenumtypehandler upgrade error of mybatis plus
- SpringBoot integrates Es error: Error creating bean with name ‘restHighLevelClient‘ defined in class path resource
- Mybatis sets the primary key Auto-Increment error: No setter found for the keyProperty
- Mybatis Error: All elements are null [How to Solve]
- Ruoyi-cloud Integrated mybatis-plus Error: Unknown column ‘search_value‘ in ‘field list‘
- mybatis Error: All elements are null [How to Solve]
- mybatis-plus Common Error and Their Solution
- [Solved] Mybatis-Plus Error: Invalid bound statement (not found)