I have an on-demand DAO like the following:
@RegisterMapper(BookMapper.class)
public interface BookDAO { @SqlQuery("select * from books order by :order_by asc limit :limit")
public List<Book> getBooks(@Bind("order_by") String orderBy, @Bind("limit") int limit);
}for some reason, though, the objects coming out appear to not be ordered by the orderBy parameters. When I change the above to
@RegisterMapper(BookMapper.class)
public interface BookDAO { @SqlQuery("select * from books order by author asc limit :limit")
public List<Book> getBooks(@Bind("limit") int limit);
}
then the query returns an ordered list as expected. For some reason, the binding on Limit also works properly. What is special about binding on the order by clause? Is there a way to specify the ordering like this?