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

org.hibernate.query.sqm.tree.domain.SqmCorrelatedRoot Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha3
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later
 * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
 */
package org.hibernate.query.sqm.tree.domain;

import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.from.SqmFrom;
import org.hibernate.query.sqm.tree.from.SqmRoot;
import org.hibernate.query.sqm.tree.select.SqmSubQuery;

/**
 * @author Steve Ebersole
 */
public class SqmCorrelatedRoot extends SqmRoot implements SqmPathWrapper, SqmCorrelation {
	private SqmRoot correlationParent;

	public SqmCorrelatedRoot(
			SqmRoot correlationParent,
			NodeBuilder nodeBuilder) {
		super( correlationParent.getReferencedPathSource(), correlationParent.getAlias(), nodeBuilder );
		this.correlationParent = correlationParent;
	}

	@Override
	public SqmRoot getCorrelationParent() {
		return correlationParent;
	}

	@Override
	public SqmPath getWrappedPath() {
		return getCorrelationParent();
	}

	@Override
	public boolean isCorrelated() {
		return true;
	}

	@Override
	public SqmFrom correlateTo(JpaSubQuery subquery) {
		final SqmSubQuery sqmSubQuery = (SqmSubQuery) subquery;
		final SqmCorrelatedRoot correlation = new SqmCorrelatedRoot<>( this, nodeBuilder() );
		sqmSubQuery.getQuerySpec().getFromClause().addRoot( correlation );
		return correlation;
	}

	@Override
	public  X accept(SemanticQueryWalker walker) {
		return walker.visitCorrelation( this );
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy