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

org.hibernate.query.internal.QueryParameterNamedImpl Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha1
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 .
 */
package org.hibernate.query.internal;

import org.hibernate.query.QueryParameter;
import org.hibernate.type.Type;

/**
 * Models a named query parameter
 *
 * NOTE: Unfortunately we need to model named and positional parameters separately still until 6.0
 *
 * NOTE : Also, notice that this still treats JPA "positional" parameters as named.  This will change in
 * 6.0 as well after we remove support for legacy positional parameters (the JPA model is better there).
 *
 * @author Steve Ebersole
 */
public class QueryParameterNamedImpl extends QueryParameterImpl implements QueryParameter {
	private final String name;
	private final int[] sourceLocations;

	public QueryParameterNamedImpl(String name, int[] sourceLocations, Type expectedType) {
		super( expectedType );
		this.name = name;
		this.sourceLocations = sourceLocations;
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public Integer getPosition() {
		return null;
	}

	@Override
	public int[] getSourceLocations() {
		return sourceLocations;
	}

	@Override
	public boolean equals(Object o) {
		if ( this == o ) {
			return true;
		}
		if ( o == null || getClass() != o.getClass() ) {
			return false;
		}

		QueryParameterNamedImpl that = (QueryParameterNamedImpl) o;
		return getName().equals( that.getName() );
	}

	@Override
	public int hashCode() {
		return getName().hashCode();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy