/*
 * 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;

import java.io.Serializable;
import java.util.Optional;

Loads an entity by its primary identifier.
Author:Eric Dalquist, Steve Ebersole
/** * Loads an entity by its primary identifier. * * @author Eric Dalquist * @author Steve Ebersole */
public interface IdentifierLoadAccess<T> {
Specify the LockOptions to use when retrieving the entity.
Params:
  • lockOptions – The lock options to use.
Returns:this, for method chaining
/** * Specify the {@link LockOptions} to use when retrieving the entity. * * @param lockOptions The lock options to use. * * @return {@code this}, for method chaining */
IdentifierLoadAccess<T> with(LockOptions lockOptions);
Specify the CacheMode to use when retrieving the entity.
Params:
  • cacheMode – The CacheMode to use.
Returns:this, for method chaining
/** * Specify the {@link CacheMode} to use when retrieving the entity. * * @param cacheMode The CacheMode to use. * * @return {@code this}, for method chaining */
IdentifierLoadAccess<T> with(CacheMode cacheMode);
Return the persistent instance with the given identifier, assuming that the instance exists. This method might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed. You should not use this method to determine if an instance exists; to check for existence, use load instead. Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.
Params:
  • id – The identifier for which to obtain a reference
Returns:the persistent instance or proxy
/** * Return the persistent instance with the given identifier, assuming that the instance exists. This method * might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed. * * You should not use this method to determine if an instance exists; to check for existence, use {@link #load} * instead. Use this only to retrieve an instance that you assume exists, where non-existence would be an * actual error. * * @param id The identifier for which to obtain a reference * * @return the persistent instance or proxy */
T getReference(Serializable id);
Return the persistent instance with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance, initializing it if needed. This method never returns an uninitialized instance.
Params:
  • id – The identifier
Returns:The persistent instance or null
/** * Return the persistent instance with the given identifier, or null if there is no such persistent instance. * If the instance is already associated with the session, return that instance, initializing it if needed. This * method never returns an uninitialized instance. * * @param id The identifier * * @return The persistent instance or {@code null} */
T load(Serializable id);
Same semantic as load except that here Optional is returned to handle nullability.
Params:
  • id – The identifier
Returns:The persistent instance, if one, wrapped in Optional
/** * Same semantic as {@link #load} except that here {@link Optional} is returned to * handle nullability. * * @param id The identifier * * @return The persistent instance, if one, wrapped in Optional */
Optional<T> loadOptional(Serializable id); }