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

org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer 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.bytecode.enhance.spi;

import java.io.Serializable;
import java.util.Collections;
import java.util.Set;

import org.hibernate.bytecode.enhance.spi.interceptor.BytecodeLazyAttributeInterceptor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;

/**
 * Contract for controlling how lazy properties get initialized.
 * 
 * @author Gavin King
 */
public interface LazyPropertyInitializer {

	/**
	 * Marker value for uninitialized properties.
	 */
	Serializable UNFETCHED_PROPERTY = new Serializable() {
		@Override
		public String toString() {
			return "";
		}

		public Object readResolve() {
			return UNFETCHED_PROPERTY;
		}
	};

	/**
	 * @deprecated Prefer the form of these methods defined on
	 * {@link BytecodeLazyAttributeInterceptor} instead
	 */
	@Deprecated
	interface InterceptorImplementor {
		default Set getInitializedLazyAttributeNames() {
			return Collections.emptySet();
		}

		default void attributeInitialized(String name) {
		}
	}

	/**
	 * Initialize the property, and return its new value.
	 *
	 * @param fieldName The name of the field being initialized
	 * @param entity The entity on which the initialization is occurring
	 * @param session The session from which the initialization originated.
	 *
	 * @return ?
	 */
	Object initializeLazyProperty(String fieldName, Object entity, SharedSessionContractImplementor session);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy