org.hibernate.metamodel.model.domain.internal.BasicSqmPathSource 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.metamodel.model.domain.internal;
import org.hibernate.metamodel.model.domain.AllowableFunctionReturnType;
import org.hibernate.metamodel.model.domain.AllowableParameterType;
import org.hibernate.metamodel.model.domain.BasicDomainType;
import org.hibernate.query.NavigablePath;
import org.hibernate.query.sqm.IllegalPathUsageException;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.tree.domain.SqmBasicValuedSimplePath;
import org.hibernate.query.sqm.tree.domain.SqmPath;
/**
* @author Steve Ebersole
*/
public class BasicSqmPathSource
extends AbstractSqmPathSource
implements AllowableParameterType, AllowableFunctionReturnType {
@SuppressWarnings("WeakerAccess")
public BasicSqmPathSource(
String localPathName,
BasicDomainType domainType,
BindableType jpaBindableType) {
super( localPathName, domainType, jpaBindableType );
}
@Override
public BasicDomainType getSqmPathType() {
//noinspection unchecked
return (BasicDomainType) super.getSqmPathType();
}
@Override
public SqmPathSource findSubPathSource(String name) {
throw new IllegalPathUsageException( "Basic paths cannot be dereferenced" );
}
@Override
public SqmPath createSqmPath(SqmPath lhs) {
final NavigablePath navigablePath = lhs.getNavigablePath().append( getPathName() );
return new SqmBasicValuedSimplePath<>(
navigablePath,
this,
lhs,
lhs.nodeBuilder()
);
}
@Override
public PersistenceType getPersistenceType() {
return PersistenceType.BASIC;
}
@Override
public Class getJavaType() {
return getExpressableJavaTypeDescriptor().getJavaTypeClass();
}
@Override
public String toString() {
return "BasicSqmPathSource(" +
getPathName() + " : " + getJavaType().getSimpleName() +
")";
}
}