Skip to content

Commit 94b43af

Browse files
committed
add overload of Hibernate.initializeProperty()
- also add missing 'static', ooops!! - improve Javadoc, and remove incorrect claim of equivalence
1 parent 48d0a60 commit 94b43af

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

hibernate-core/src/main/java/org/hibernate/Hibernate.java

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -302,27 +302,31 @@ public static boolean isInstance(Object proxy, Class<?> entityClass) {
302302

303303
/**
304304
* Determines if the given attribute of the given entity instance is initialized.
305+
* This operation returns {@code true} if the field or property references an
306+
* unfetched collection or proxy.
305307
*
306308
* @param entity The entity instance or proxy
307309
* @param attribute A persistent attribute of the entity
308310
* @return true if the named property of the object is not listed as uninitialized;
309311
* false otherwise
310312
*/
311-
public <E> boolean isPropertyInitialized(E entity, Attribute<? super E, ?> attribute) {
313+
public static <E> boolean isPropertyInitialized(E entity, Attribute<? super E, ?> attribute) {
312314
return isPropertyInitialized( entity, attribute.getName() );
313315
}
314316

315317
/**
316-
* Determines if the property with the given name of the given entity instance is
317-
* initialized. If the named property does not exist or is not persistent, this
318-
* method always returns {@code true}.
319-
* <p>
320-
* This operation is equivalent to {@link jakarta.persistence.PersistenceUtil#isLoaded(Object, String)}.
318+
* Determines if the field or property with the given name of the given entity
319+
* instance is initialized. If the named property does not exist or is not
320+
* persistent, this method always returns {@code true}. This operation returns
321+
* {@code true} if the field or property references an unfetched collection or
322+
* proxy.
321323
*
322324
* @param proxy The entity instance or proxy
323325
* @param attributeName the name of a persistent attribute of the object
324326
* @return true if the named property of the object is not listed as uninitialized;
325327
* false otherwise
328+
*
329+
* @see jakarta.persistence.PersistenceUtil#isLoaded(Object, String)
326330
*/
327331
public static boolean isPropertyInitialized(Object proxy, String attributeName) {
328332
final Object entity;
@@ -348,12 +352,25 @@ && getAttributeInterceptor( entity )
348352
}
349353

350354
/**
351-
* Initializes the property with the given name of the given entity instance.
352-
* <p>
353-
* This operation is equivalent to {@link jakarta.persistence.PersistenceUnitUtil#load(Object, String)}.
355+
* Initializes the given attribute of the given entity instance. This operation
356+
* does not fetch a collection or proxy referenced by the field or property.
357+
*
358+
* @param entity The entity instance or proxy
359+
* @param attribute A persistent attribute of the entity
360+
*/
361+
public static <E> void initializeProperty(E entity, Attribute<? super E, ?> attribute) {
362+
initializeProperty( entity, attribute.getName() );
363+
}
364+
365+
/**
366+
* Initializes the field or property with the given name of the given entity
367+
* instance. This operation does not fetch a collection or proxy referenced
368+
* by the field or property.
354369
*
355370
* @param proxy The entity instance or proxy
356371
* @param attributeName the name of a persistent attribute of the object
372+
*
373+
* @see jakarta.persistence.PersistenceUnitUtil#load(Object, String)
357374
*/
358375
public static void initializeProperty(Object proxy, String attributeName) {
359376
final LazyInitializer lazyInitializer = extractLazyInitializer( proxy );

0 commit comments

Comments
 (0)