org.hibernate.query.criteria.internal.expression.ParameterExpressionImpl 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 .
*/
package org.hibernate.query.criteria.internal.expression;
import java.io.Serializable;
import javax.persistence.criteria.ParameterExpression;
import org.hibernate.query.criteria.internal.CriteriaBuilderImpl;
import org.hibernate.query.criteria.internal.ParameterRegistry;
import org.hibernate.query.criteria.internal.compile.ExplicitParameterInfo;
import org.hibernate.query.criteria.internal.compile.RenderingContext;
/**
* Defines a parameter specification, or the information about a parameter (where it occurs, what is
* its type, etc).
*
* @author Steve Ebersole
*/
public class ParameterExpressionImpl
extends ExpressionImpl
implements ParameterExpression, Serializable {
private final String name;
private final Integer position;
public ParameterExpressionImpl(
CriteriaBuilderImpl criteriaBuilder,
Class javaType,
String name) {
super( criteriaBuilder, javaType );
this.name = name;
this.position = null;
}
public ParameterExpressionImpl(
CriteriaBuilderImpl criteriaBuilder,
Class javaType,
Integer position) {
super( criteriaBuilder, javaType );
this.name = null;
this.position = position;
}
public ParameterExpressionImpl(
CriteriaBuilderImpl criteriaBuilder,
Class javaType) {
super( criteriaBuilder, javaType );
this.name = null;
this.position = null;
}
@Override
public String getName() {
return name;
}
@Override
public Integer getPosition() {
return position;
}
@Override
public Class getParameterType() {
return getJavaType();
}
@Override
public void registerParameters(ParameterRegistry registry) {
registry.registerParameter( this );
}
@Override
public String render(RenderingContext renderingContext) {
final ExplicitParameterInfo parameterInfo = renderingContext.registerExplicitParameter( this );
return parameterInfo.render();
}
}