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