Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public boolean elementExists(Object element) {
}
}

protected static final Object UNKNOWN = new MarkerObject( "UNKNOWN" );
protected static final MarkerObject UNKNOWN = MarkerObject.UNKNOWN;

protected Object readElementByIndex(final Object index) {
if ( !initialized ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public interface PersistenceContext {
/**
* Marker object used to indicate (via reference checking) that no row was returned.
*/
Object NO_ROW = new MarkerObject( "NO_ROW" );
MarkerObject NO_ROW = MarkerObject.NO_ROW;

boolean isStateless();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,52 @@
*/
package org.hibernate.internal.util;

import java.io.Serializable;

/**
* @deprecated This is a legacy of very ancient versions of Hibernate.
* Marker objects used throughout Hibernate to represent special sentinel values.
* These are used for reference-equality checks (==) to indicate special states
* like "no row found", "unfetched collection", etc.
*
* <p>Implemented as an enum to ensure proper singleton behavior across serialization
* and deserialization, fixing issues where marker object identity was lost after
* deserialization (e.g., in clustered environments or session serialization scenarios).
*
* @author Gavin King
* @see <a href="https://hibernate.atlassian.net/browse/HHH-9414">HHH-9414</a>
*/
@Deprecated
public class MarkerObject implements Serializable {
public enum MarkerObject {
/**
* Marker indicating that no row was returned from the database.
*/
NO_ROW("NO_ROW"),

/**
* Marker used in proxy implementations to signal that the actual
* implementation method should be invoked.
*/
INVOKE_IMPLEMENTATION("INVOKE_IMPLEMENTATION"),

/**
* Marker indicating an unknown state in persistent collections.
*/
UNKNOWN("UNKNOWN"),

/**
* Marker indicating a collection that has not yet been fetched from the database.
*/
UNFETCHED_COLLECTION("UNFETCHED COLLECTION"),

/**
* Marker representing a null discriminator value.
*/
NULL_DISCRIMINATOR("<null discriminator>"),

/**
* Marker representing a not-null discriminator value.
*/
NOT_NULL_DISCRIMINATOR("<not null discriminator>");

private final String name;

public MarkerObject(String name) {
MarkerObject(String name) {
this.name = name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
@Internal
public class DiscriminatorHelper {

public static final Object NULL_DISCRIMINATOR = new MarkerObject( "<null discriminator>" );
public static final Object NOT_NULL_DISCRIMINATOR = new MarkerObject( "<not null discriminator>" );
public static final MarkerObject NULL_DISCRIMINATOR = MarkerObject.NULL_DISCRIMINATOR;
public static final MarkerObject NOT_NULL_DISCRIMINATOR = MarkerObject.NOT_NULL_DISCRIMINATOR;

/**
* The underlying BasicType as the "JDBC mapping" between the relational {@link org.hibernate.type.descriptor.java.JavaType}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
public abstract class BasicLazyInitializer extends AbstractLazyInitializer {

protected static final Object INVOKE_IMPLEMENTATION = new MarkerObject( "INVOKE_IMPLEMENTATION" );
protected static final MarkerObject INVOKE_IMPLEMENTATION = MarkerObject.INVOKE_IMPLEMENTATION;

protected final Class<?> persistentClass;
protected final Method getIdentifierMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
public abstract class CollectionType extends AbstractType implements AssociationType {

@Internal
public static final Object UNFETCHED_COLLECTION = new MarkerObject( "UNFETCHED COLLECTION" );
public static final MarkerObject UNFETCHED_COLLECTION = MarkerObject.UNFETCHED_COLLECTION;

private final String role;
private final String foreignKeyPropertyName;
Expand Down