Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

异常没有抛出导致查询结果有误 #378

Closed
xingfenhao opened this issue Jul 5, 2018 · 1 comment
Closed

异常没有抛出导致查询结果有误 #378

xingfenhao opened this issue Jul 5, 2018 · 1 comment

Comments

@xingfenhao
Copy link

xingfenhao commented Jul 5, 2018

PaginationInterceptor.queryTotal
异常场景还原:
try (PreparedStatement statement = connection.prepareStatement(sql)) {
DefaultParameterHandler parameterHandler = new MybatisDefaultParameterHandler(mappedStatement, boundSql.getParameterObject(), boundSql);
parameterHandler.setParameters(statement);
int total = 0;
try (ResultSet resultSet = statement.executeQuery()) {
if (resultSet.next()) {
total = resultSet.getInt(1);
}
}
page.setTotal(total);
/*
* 溢出总页数,设置第一页
*/
int pages = page.getPages();
if (overflowCurrent && (page.getCurrent() > pages)) {
page = new Pagination(1, page.getSize());
page.setTotal(total);
}
} catch (Exception e) {
logger.error("Error: Method queryTotal execution error !", e);
}
如上代码, statement.executeQuery()执行sql的列有重复,则会有异常:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate column name 'status',
但是catch后没有抛出,导致 page.total默认0

@qmdx
Copy link
Member

qmdx commented Jul 5, 2018

感谢反馈已修复 1bf620f

@qmdx qmdx closed this as completed Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants