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

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

There is a newer version: 7.0.0.Beta1
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.metamodel.model.domain.EntityDomainType;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.from.SqmRoot;

/**
 * @author Steve Ebersole
 */
public class SqmTreatedRoot extends SqmRoot implements SqmTreatedPath {
	private final SqmRoot wrappedPath;
	private final EntityDomainType treatTarget;

	public SqmTreatedRoot(
			SqmRoot wrappedPath,
			EntityDomainType treatTarget,
			NodeBuilder nodeBuilder) {
		//noinspection unchecked
		super(
				(EntityDomainType) wrappedPath.getReferencedPathSource(),
				null,
				nodeBuilder
		);
		this.wrappedPath = wrappedPath;
		this.treatTarget = treatTarget;
	}

	@Override
	public EntityDomainType getTreatTarget() {
		return treatTarget;
	}

	@Override
	public EntityDomainType getManagedType() {
		return getTreatTarget();
	}

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

	@Override
	public EntityDomainType getReferencedPathSource() {
		//noinspection unchecked
		return (EntityDomainType) wrappedPath.getReferencedPathSource();
	}

	@Override
	public SqmPath getLhs() {
		return wrappedPath.getLhs();
	}

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