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