Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

queryDSL

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.

exports

  • SQLQueryFactory

dependency

<dependency>
 <groupId>org.jooby</groupId>
 <artifactId>jooby-querydsl</artifactId>
 <version>1.0.3</version>
</dependency>

usage

import org.jooby.querydsl.QueryDSL;
{
  use(new QueryDSL());

  get("/my-api", req -> {

    SQLQueryFactory queryFactory = require(SQLQueryFactory.class);
    // Do something with the database
    ...
  });

}

dialects

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());
}

multiple databases

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
  });
}

advanced configuration

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(...);
  });
}

code generation

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.