All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.micronaut.data.model.jpa.criteria.impl.AbstractPersistentEntitySubquery Maven / Gradle / Ivy

There is a newer version: 4.11.0
Show newest version
/*
 * Copyright 2017-2021 original authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.micronaut.data.model.jpa.criteria.impl;

import io.micronaut.core.annotation.Internal;
import io.micronaut.data.model.jpa.criteria.ExpressionType;
import io.micronaut.data.model.jpa.criteria.IExpression;
import io.micronaut.data.model.jpa.criteria.PersistentEntityCriteriaQuery;
import io.micronaut.data.model.jpa.criteria.PersistentEntitySubquery;
import jakarta.persistence.criteria.AbstractQuery;
import jakarta.persistence.criteria.CollectionJoin;
import jakarta.persistence.criteria.CommonAbstractCriteria;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.Expression;
import jakarta.persistence.criteria.Join;
import jakarta.persistence.criteria.ListJoin;
import jakarta.persistence.criteria.MapJoin;
import jakarta.persistence.criteria.Order;
import jakarta.persistence.criteria.Root;
import jakarta.persistence.criteria.SetJoin;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;

/**
 * The abstract implementation of {@link PersistentEntityCriteriaQuery}.
 *
 * @param  The entity type
 * @author Denis Stepanov
 * @since 4.10
 */
@Internal
public abstract class AbstractPersistentEntitySubquery extends AbstractPersistentEntityQuery>
    implements PersistentEntitySubquery, IExpression {

    private final AbstractQuery parentQuery;

    protected AbstractPersistentEntitySubquery(AbstractQuery parentQuery, ExpressionType resultType, CriteriaBuilder criteriaBuilder) {
        super(resultType, criteriaBuilder);
        this.parentQuery = parentQuery;
    }

    @Override
    public PersistentEntitySubquery orderBy(Order... orders) {
        this.orders = Arrays.asList(Objects.requireNonNull(orders));
        return this;
    }

    @Override
    public PersistentEntitySubquery orderBy(List orders) {
        this.orders = Objects.requireNonNull(orders);
        return this;
    }

    @Override
    public AbstractQuery getParent() {
        return parentQuery;
    }

    @Override
    protected PersistentEntitySubquery self() {
        return this;
    }

    @Override
    public IExpression getSelection() {
        return (IExpression) super.getSelection();
    }

    @Override
    public ExpressionType getExpressionType() {
        return getSelection().getExpressionType();
    }

    @Override
    public void visitExpression(ExpressionVisitor expressionVisitor) {
        expressionVisitor.visit(this);
    }

    @Override
    public PersistentEntitySubquery select(Expression expression) {
        this.selection = expression;
        return this;
    }

    @Override
    public Set> getCorrelatedJoins() {
        throw CriteriaUtils.notSupportedOperation();
    }

    @Override
    public CommonAbstractCriteria getContainingQuery() {
        throw CriteriaUtils.notSupportedOperation();
    }

    @Override
    public  MapJoin correlate(MapJoin parentMap) {
        throw CriteriaUtils.notSupportedOperation();
    }

    @Override
    public  ListJoin correlate(ListJoin parentList) {
        throw CriteriaUtils.notSupportedOperation();
    }

    @Override
    public  SetJoin correlate(SetJoin parentSet) {
        throw CriteriaUtils.notSupportedOperation();
    }

    @Override
    public  CollectionJoin correlate(CollectionJoin parentCollection) {
        throw CriteriaUtils.notSupportedOperation();
    }

    @Override
    public  Join correlate(Join parentJoin) {
        throw CriteriaUtils.notSupportedOperation();
    }

    @Override
    public  Root correlate(Root parentRoot) {
        throw CriteriaUtils.notSupportedOperation();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy