org.hibernate.query.sqm.tree.domain.SqmTreatedSimplePath Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core-jakarta Show documentation
Show all versions of hibernate-core-jakarta Show documentation
Hibernate O/RM implementation of the Jakarta Persistence specification
The 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.PathException;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SemanticQueryWalker;
/**
* @author Steve Ebersole
*/
public class SqmTreatedSimplePath
extends SqmEntityValuedSimplePath
implements SqmSimplePath, SqmTreatedPath {
private final EntityDomainType treatTarget;
private final SqmPath wrappedPath;
@SuppressWarnings({"unchecked", "WeakerAccess"})
public SqmTreatedSimplePath(
SqmPluralValuedSimplePath wrappedPath,
EntityDomainType treatTarget,
NodeBuilder nodeBuilder) {
super(
wrappedPath.getNavigablePath(),
(EntityDomainType) wrappedPath.getReferencedPathSource(),
wrappedPath.getLhs(),
nodeBuilder
);
this.treatTarget = treatTarget;
this.wrappedPath = wrappedPath;
}
@SuppressWarnings({"unchecked", "WeakerAccess"})
public SqmTreatedSimplePath(
SqmPath wrappedPath,
EntityDomainType treatTarget,
NodeBuilder nodeBuilder) {
super(
wrappedPath.getNavigablePath(),
(EntityDomainType) wrappedPath.getReferencedPathSource(),
wrappedPath.getLhs(),
nodeBuilder
);
this.treatTarget = treatTarget;
this.wrappedPath = wrappedPath;
}
@Override
public EntityDomainType getTreatTarget() {
return treatTarget;
}
@Override
public SqmPath getWrappedPath() {
return wrappedPath;
}
@Override
public SqmTreatedSimplePath treatAs(Class treatJavaType) throws PathException {
return super.treatAs( treatJavaType );
}
@Override
public X accept(SemanticQueryWalker walker) {
return walker.visitTreatedPath( this );
}
@Override
public void appendHqlString(StringBuilder sb) {
sb.append( "treat(" );
wrappedPath.appendHqlString( sb );
sb.append( " as " );
sb.append( treatTarget.getName() );
sb.append( ')' );
}
}