SQL abstraction provided by QueryDSL using plain JDBC underneath.
This module depends on jdbc module, make sure you read the doc of the jdbc module module before using this module.
SQLQueryFactory
<dependency>
<groupId>org.jooby</groupId>
<artifactId>jooby-querydsl</artifactId>
<version>1.0.3</version>
</dependency>import org.jooby.querydsl.QueryDSL;
{
use(new QueryDSL());
get("/my-api", req -> {
SQLQueryFactory queryFactory = require(SQLQueryFactory.class);
// Do something with the database
...
});
}Dialect is detected automatically and usually you don't need to do anything. But if the default dialect detector doesn't work and/or you have a custom dialect:
{
use(new QueryDSL().with(new MyCustomTemplates());
}import org.jooby.querydsl.QueryDSL;
{
use(new QueryDSL("db.main"));
use(new QueryDSL("db.aux"));
get("/my-api", req -> {
SQLQueryFactory queryFactory = require("db.main", SQLQueryFactory.class);
// Do something with the database
});
}This module builds QueryDSL SQLQueryFactories on top of a default Configuration object, a SQLTemplates instance and a javax.sql.DataSource from the jdbc module.
Advanced configuration can be added by invoking the doWith method, adding your own settings to the configuration.
{
use(new QueryDSL().doWith(conf -> {
conf.set(...);
});
}This module does not provide code generation for DB mapping classes. To learn how to create QueryDSL mapping classes using Maven, please consult the QueryDSL documentation.