public class QueryDSL extends Object implements org.jooby.Jooby.Module
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 Jdbc());
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 Jdbc());
use(new QueryDSL().with(new MyCustomTemplates());
}
import org.jooby.querydsl.QueryDSL;
{
use(new Jdbc("db.main"));
use(new QueryDSL("db.main"));
use(new Jdbc("db.aux"));
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 doWith(BiConsumer) method, adding
your own settings to the configuration.
{
use(new Jdbc());
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 |
doWith(BiConsumer<com.querydsl.sql.Configuration,com.typesafe.config.Config> configurer) |
QueryDSL |
doWith(Consumer<com.querydsl.sql.Configuration> configurer) |
QueryDSL |
with(com.querydsl.sql.SQLTemplates templates) |
public QueryDSL(String name)
QueryDSL modulename - Database namepublic QueryDSL()
QueryDSL modulepublic void configure(org.jooby.Env env,
com.typesafe.config.Config conf,
com.google.inject.Binder binder)
configure in interface org.jooby.Jooby.Modulepublic QueryDSL doWith(BiConsumer<com.querydsl.sql.Configuration,com.typesafe.config.Config> configurer)
public QueryDSL with(com.querydsl.sql.SQLTemplates templates)
Copyright © 2017. All rights reserved.