oblac / jodd

Jodd! Lightweight. Java. Zero dependencies. Use what you like.
https://jodd.org
BSD 2-Clause "Simplified" License
4.06k stars 723 forks source link

count failed in jodd.joy.page.DbPager (line 64) #71

Closed shawnye closed 10 years ago

shawnye commented 10 years ago

jodd-version:3.4.10

When I run into the follow method with NOT-EMPTY params, errors happend: org.hsqldb.HsqlException: Parameter not set

Code:

protected <T> PageData<T> page(String sql, int page, int pageSize, Map params, int sort, String[] sortColumns, Class[] target) 

when run the line 58~60:

query.setMap(params);

List<T> list = query.listAndClose(pageSize, target);

I found query.preparedStatement.parameters is NOT EMPTY and run correctly,

But when run count sql, error happened in error line=64:

long count = query(dbsql).executeCountAndClose();

I found query.preparedStatement.parameters is EMPTY

I've stucked here several days, Is it my misuse or a bug ?

igr commented 10 years ago

I think you have found a bug ;) We are not setting the parameters map for line 64. So that line should be replaced with something like this:

query = query(dbsql);
query.setMap(params);
long count = query.executeCountAndClose();

Would you be so kind to check if this works for you, if you already have everything setup? Thank you!

shawnye commented 10 years ago

I'm building a slim project on top of jodd, adding main features step by step in contrast of my other project (on top of struts2), if I should find something I don't know why, I would notice you.

igr commented 10 years ago

Great :) I hope you develop without much trouble :) Feel free to share the experience and project when done!