org.hibernate.query.sqm.tree.domain.SqmListJoin 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 java.util.List;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Predicate;
import javax.persistence.metamodel.PluralAttribute;
import javax.persistence.metamodel.SingularAttribute;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.metamodel.model.domain.ListPersistentAttribute;
import org.hibernate.query.NavigablePath;
import org.hibernate.query.PathException;
import org.hibernate.query.criteria.JpaExpression;
import org.hibernate.query.criteria.JpaListJoin;
import org.hibernate.query.criteria.JpaPredicate;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.hql.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
import org.hibernate.query.sqm.tree.from.SqmFrom;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
/**
* @author Steve Ebersole
*/
public class SqmListJoin
extends AbstractSqmPluralJoin, E>
implements JpaListJoin {
public SqmListJoin(
SqmFrom lhs,
ListPersistentAttribute listAttribute,
String alias,
SqmJoinType sqmJoinType,
boolean fetched,
NodeBuilder nodeBuilder) {
super( lhs, listAttribute, alias, sqmJoinType, fetched, nodeBuilder );
}
@Override
public ListPersistentAttribute getModel() {
return (ListPersistentAttribute) super.getModel();
}
@Override
public ListPersistentAttribute getReferencedPathSource() {
//noinspection unchecked
return (ListPersistentAttribute) super.getReferencedPathSource();
}
@Override
public JavaTypeDescriptor getJavaTypeDescriptor() {
return getNodeJavaTypeDescriptor();
}
@Override
public SqmPath index() {
final String navigableName = "{index}";
final NavigablePath navigablePath = getNavigablePath().append( navigableName );
//noinspection unchecked
return new SqmBasicValuedSimplePath<>(
navigablePath,
( (ListPersistentAttribute) getReferencedPathSource() ).getIndexPathSource(),
this,
nodeBuilder()
);
}
@Override
public SqmListJoin on(JpaExpression restriction) {
return (SqmListJoin) super.on( restriction );
}
@Override
public SqmListJoin on(Expression restriction) {
return (SqmListJoin) super.on( restriction );
}
@Override
public SqmListJoin on(JpaPredicate... restrictions) {
return (SqmListJoin) super.on( restrictions );
}
@Override
public SqmListJoin on(Predicate... restrictions) {
return (SqmListJoin) super.on( restrictions );
}
@Override
public SqmListJoin correlateTo(JpaSubQuery subquery) {
return (SqmListJoin) super.correlateTo( subquery );
}
@Override
public SqmTreatedListJoin treatAs(Class treatAsType) {
return treatAs( nodeBuilder().getDomainModel().entity( treatAsType ) );
}
@Override
public SqmTreatedListJoin treatAs(EntityDomainType treatTarget) throws PathException {
//noinspection unchecked
return new SqmTreatedListJoin( this, treatTarget, null );
}
@Override
public SqmSingularJoin fetch(SingularAttribute attribute) {
throw new NotYetImplementedFor6Exception();
}
@Override
public SqmSingularJoin fetch(SingularAttribute attribute, JoinType jt) {
throw new NotYetImplementedFor6Exception();
}
@Override
public SqmAttributeJoin fetch(PluralAttribute attribute) {
throw new NotYetImplementedFor6Exception();
}
@Override
public SqmAttributeJoin fetch(PluralAttribute attribute, JoinType jt) {
throw new NotYetImplementedFor6Exception();
}
@Override
public SqmAttributeJoin fetch(String attributeName) {
throw new NotYetImplementedFor6Exception();
}
@Override
public SqmAttributeJoin fetch(String attributeName, JoinType jt) {
throw new NotYetImplementedFor6Exception();
}
@Override
public SqmAttributeJoin makeCopy(SqmCreationProcessingState creationProcessingState) {
//noinspection unchecked
return new SqmListJoin(
creationProcessingState.getPathRegistry().findFromByPath( getLhs().getNavigablePath() ),
getReferencedPathSource(),
getExplicitAlias(),
getSqmJoinType(),
isFetched(),
nodeBuilder()
);
}
}