mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-28 14:59:12 +00:00
add Hibernate.isInstance() convenience method
This commit is contained in:
parent
5160ac3192
commit
fae1ec40fd
@ -186,8 +186,8 @@ public static <T> T get(List<T> list, int key) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the true, underlying class of a proxied persistent class. This operation
|
||||
* will initialize a proxy by side effect.
|
||||
* Get the true, underlying class of a proxied entity. This operation will
|
||||
* initialize a proxy by side effect.
|
||||
*
|
||||
* @param proxy an entity instance or proxy
|
||||
* @return the true class of the instance
|
||||
@ -206,6 +206,20 @@ public static <T> Class<? extends T> getClass(T proxy) {
|
||||
return (Class<? extends T>) result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the true, underlying class of the proxied entity is assignable
|
||||
* to the given class. This operation will initialize a proxy by side effect.
|
||||
*
|
||||
* @param proxy an entity instance or proxy
|
||||
* @return {@code true} if the entity is an instance of the given class
|
||||
*
|
||||
* @since 6.2
|
||||
*/
|
||||
public static boolean isInstance(Object proxy, Class<?> entityClass) {
|
||||
return entityClass.isInstance( proxy )
|
||||
|| entityClass.isAssignableFrom( getClass( proxy ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the property with the given name of the given entity instance is
|
||||
* initialized. If the named property does not exist or is not persistent, this
|
||||
|
Loading…
x
Reference in New Issue
Block a user