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

org.springframework.data.jpa.repository.support.QueryHints Maven / Gradle / Ivy

There is a newer version: 3.3.2
Show newest version
package org.springframework.data.jpa.repository.support;

import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import javax.persistence.EntityManager;

/**
 * QueryHints provides access to query hints defined via {@link CrudMethodMetadata#getQueryHints()} by default excluding
 * JPA {@link javax.persistence.EntityGraph}.
 *
 * @author Christoph Strobl
 * @author Oliver Gierke
 * @since 2.0
 */
interface QueryHints extends Iterable> {

	/**
	 * Creates and returns a new {@link QueryHints} instance including {@link javax.persistence.EntityGraph}.
	 *
	 * @param em must not be {@literal null}.
	 * @return new instance of {@link QueryHints}.
	 */
	QueryHints withFetchGraphs(EntityManager em);

	/**
	 * Get the query hints as a {@link Map}.
	 *
	 * @return never {@literal null}.
	 */
	Map asMap();

	/**
	 * Null object implementation of {@link QueryHints}.
	 *
	 * @author Oliver Gierke
	 * @since 2.0
	 */
	static enum NoHints implements QueryHints {

		INSTANCE;

		/* 
		 * (non-Javadoc)
		 * @see org.springframework.data.jpa.repository.support.QueryHints#asMap()
		 */
		@Override
		public Map asMap() {
			return Collections.emptyMap();
		}

		/* 
		 * (non-Javadoc)
		 * @see java.lang.Iterable#iterator()
		 */
		@Override
		public Iterator> iterator() {
			return Collections.emptyIterator();
		}

		/* 
		 * (non-Javadoc)
		 * @see org.springframework.data.jpa.repository.support.QueryHints#withFetchGraphs(javax.persistence.EntityManager)
		 */
		@Override
		public QueryHints withFetchGraphs(EntityManager em) {
			return this;
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy