org.hibernate.query.sqm.tree.domain.SqmCorrelatedRoot Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
Hibernate's core ORM functionality
/*
* 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 );
}
}