Querity is an extensible query builder to create and run database queries in your Java application. It supports SQL and NoSQL databases technologies, and each support is built into small modules, so ...
Plenty of samples and use cases are covered in the documentation.