Skip to content

laboratoriobridge/querydsl-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status codecov Maven Central

QueryDSL Utils

Select

Select uses meta information generated by Metafy to bind query values to DTO values.

Example:

QAuthor author = QAuthor.author;
MAuthorDto meta = MAuthorDto.meta;

Select<AuthorDto> select = new Select<>(AuthorDto.class);
select.as(author.id, meta.id);
select.as(author.name, meta.name);

JPAQuery<AuthorDto> query = new JPAQuery<>(em);
query.from(author);

List<AuthorDto> authors = query.select(select).fetch();

Using converters:

QAuthor author = QAuthor.author;
MAuthorDto meta = MAuthorDto.meta;

Select<AuthorDto> select = new Select<>(AuthorDto.class);
select.as(author.id, meta.id);
select.as(author.name, meta.name, name -> name + "_converted-name");

JPAQuery<AuthorDto> query = new JPAQuery<>(em);
query.from(author);

List<AuthorDto> authors = query.select(select).fetch();

QueryWrapper

Adds utilities to the Query.

Paging example:

QAuthor author = QAuthor.author;
MAuthorDto meta = MAuthorDto.meta;

Select<AuthorDto> select = new Select<>(AuthorDto.class);
select.as(author.id, meta.id);
select.as(author.name, meta.name);

JPAQuery<AuthorDto> query = new JPAQuery<>(em);
query.from(author);
query.select(select);

QueryWrapper<AuthorDto, JPAQuery<AuthorDto>> wrapper = QueryWrapper.wrap(query);

PageSpec pageSpec = new PageSpec(0, 1, null);

PageResult<AuthorDto> result = wrapper.fetchPage(pageSpec);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages