add Hibernate.isInstance() convenience method
This commit is contained in:
parent
5160ac3192
commit
fae1ec40fd
|
@ -186,8 +186,8 @@ public final class Hibernate {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the true, underlying class of a proxied persistent class. This operation
|
* Get the true, underlying class of a proxied entity. This operation will
|
||||||
* will initialize a proxy by side effect.
|
* initialize a proxy by side effect.
|
||||||
*
|
*
|
||||||
* @param proxy an entity instance or proxy
|
* @param proxy an entity instance or proxy
|
||||||
* @return the true class of the instance
|
* @return the true class of the instance
|
||||||
|
@ -206,6 +206,20 @@ public final class Hibernate {
|
||||||
return (Class<? extends T>) result;
|
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
|
* 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
|
* initialized. If the named property does not exist or is not persistent, this
|
||||||
|
|
Loading…
Reference in New Issue