public class QueryDSL extends Jdbc
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 before using this module.
import org.jooby.querydsl.QueryDSL;
{
use(new QueryDSL());
get("/my-api", req -> {
SQLQueryFactory queryFactory = req.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 = req.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 DataSource from the Jdbc module.
Advanced configuration can be added by invoking the Jdbc.doWith(BiConsumer) 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.
| Constructor and Description |
|---|
QueryDSL()
Creates a new
QueryDSL module |
QueryDSL(String name)
Creates a new
QueryDSL module |
| Modifier and Type | Method and Description |
|---|---|
void |
configure(org.jooby.Env env,
com.typesafe.config.Config conf,
com.google.inject.Binder binder) |
QueryDSL |
with(com.querydsl.sql.SQLTemplates templates) |
Copyright © 2017. All rights reserved.