Skip to content

Implement class-based DTO projections for Fluent API #2327

Closed
@gregturn

Description

@gregturn

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions