Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement class-based DTO projections for Fluent API #2327

Closed
gregturn opened this issue Oct 7, 2021 · 1 comment
Closed

Implement class-based DTO projections for Fluent API #2327

gregturn opened this issue Oct 7, 2021 · 1 comment
Assignees
Labels
theme: projections Refinements around DTO and interface projections type: enhancement A general enhancement

Comments

@gregturn
Copy link
Contributor

gregturn commented Oct 7, 2021

#2294 introduced the Fluent API. However, scheduling issues prevented us from implementing class-based DTOs.

As part of that development effort, the following chunk of code from FetchableFluentQueryByExample was withdrawn since it isn't relevant to everything.

	/**
	 * Draft version of a projection-based query using class-based DTOs.
	 *
	 * @param sort
	 * @param queryType
	 * @param example
	 * @return
	 */
	private TypedQuery<R> createProjectionQueryByExample(Sort sort, Class<R> queryType, Example<S> example) {

		CriteriaBuilder builder = this.entityManager.getCriteriaBuilder();
		CriteriaQuery<R> query = builder.createQuery(queryType);

		Root<R> root = query.from(queryType);
		query.select(root);

		Predicate predicate = QueryByExamplePredicateBuilder.getPredicate(
				builder.createQuery(example.getProbeType()).from(example.getProbeType()), builder, example, escapeCharacter);

		if (predicate != null) {
			query.where(predicate);
		}

		if (sort.isSorted()) {
			query.orderBy(toOrders(sort, root, builder));
		}

		return this.entityManager.createQuery(query);
	}
gregturn added a commit that referenced this issue Oct 7, 2021
Add support for both QueryByExampleExecutor and QuerydslPredicateExecutor. This is used in SimpleJpaRepository and QuerydslJpaPredicateExecutor, resulting in various test cases proving support by both examples and Querydsl predicates.

NOTE: Class-based DTOs are NOT supported yet.

Closes #2294.

Related: #2327.
@schauder schauder self-assigned this Oct 27, 2021
@gregturn gregturn assigned markpollack and odrotbohm and unassigned schauder and markpollack Nov 2, 2021
@gregturn
Copy link
Contributor Author

gregturn commented Apr 19, 2022

Related: 8cd1388
Related: #487

@gregturn gregturn self-assigned this Apr 29, 2022
@mp911de mp911de added the theme: projections Refinements around DTO and interface projections label Aug 13, 2024
@mp911de mp911de assigned mp911de and unassigned odrotbohm and gregturn Sep 24, 2024
@mp911de mp911de linked a pull request Oct 28, 2024 that will close this issue
@mp911de mp911de added the type: enhancement A general enhancement label Oct 28, 2024
@mp911de mp911de added this to the 3.5 M1 (2025.0.0) milestone Dec 3, 2024
mp911de added a commit that referenced this issue Dec 3, 2024
Also, interface-based projections now use Tuple queries to consistently use tuple-based queries.

Closes #2327
mp911de added a commit that referenced this issue Dec 3, 2024
Refactor code duplications.

See #2327
mp911de pushed a commit that referenced this issue Dec 3, 2024
There's a difference in what the query needs to look like using dto vs. interface projections where the former does not allow column aliases and the latter requires them.

See #2327
mp911de added a commit that referenced this issue Dec 3, 2024
Simplify Querydsl templates retrieva and String query caching. Update documentation. Skip selection list rewriting if the returned type is an interface.

Encapsulate rewrite information for Query.

Reformat code.

See #2327
christophstrobl pushed a commit that referenced this issue Dec 5, 2024
Also, interface-based projections now use Tuple queries to consistently use tuple-based queries.

Closes #2327
christophstrobl pushed a commit that referenced this issue Dec 5, 2024
Refactor code duplications.

See #2327
christophstrobl added a commit that referenced this issue Dec 5, 2024
There's a difference in what the query needs to look like using dto vs. interface projections where the former does not allow column aliases and the latter requires them.

See #2327
christophstrobl pushed a commit that referenced this issue Dec 5, 2024
Simplify Querydsl templates retrieva and String query caching. Update documentation. Skip selection list rewriting if the returned type is an interface.

Encapsulate rewrite information for Query.

Reformat code.

See #2327
@mp911de mp911de changed the title Implement class-based DTOs for Fluent API Implement class-based DTO projections for Fluent API Dec 16, 2024
christophstrobl pushed a commit that referenced this issue Dec 17, 2024
See: #2327
Original Pull Request: #3654
christophstrobl added a commit that referenced this issue Dec 17, 2024
There's a difference in what the query needs to look like using dto vs. interface projections where the former does not allow column aliases and the latter requires them.

See: #2327
Original Pull Request: #3654
christophstrobl pushed a commit that referenced this issue Dec 17, 2024
Simplify Querydsl templates retrieve and String query caching. Update documentation. Skip selection list rewriting if the returned type is an interface.

Encapsulate rewrite information for Query.

Reformat code.

See: #2327
Original Pull Request: #3654
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: projections Refinements around DTO and interface projections type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants