Package com.axelor.db
Class EntityHelper
java.lang.Object
com.axelor.db.EntityHelper
This class provides helper methods for model objects.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Model>
booleanThe equals helper method.static <T> TgetEntity(T entity) Get unproxied instance of the given entity.static <T> Class<T> getEntityClass(T entity) Get the real persistence class of the given entity.static <T> booleanisUninitialized(T entity) Check whether the given lazy loading proxy instance is uninitialized.toString(T entity) The toString helper method.
-
Constructor Details
-
EntityHelper
public EntityHelper()
-
-
Method Details
-
toString
The toString helper method.- Type Parameters:
T- type of the entity- Parameters:
entity- generate toString for the given entity- Returns:
- string
-
equals
The equals helper method.This method searches for all the fields marked with
EqualsIncludeand uses them to check for the equality.- Type Parameters:
T- type of the entity- Parameters:
entity- the current entityother- the other entity- Returns:
- true if both objects are equal by their fields included for equality check
-
getEntityClass
Get the real persistence class of the given entity.This method can be used to find real class name of a proxy object returned by hibernate entity manager or
Context.asType(Class)instance.- Type Parameters:
T- type of the entity- Parameters:
entity- an entity instance- Returns:
- real class of the entity
-
getEntity
public static <T> T getEntity(T entity) Get unproxied instance of the given entity.This method can be used to convert hibernate proxy object to real implementation instance.
If called for instances returned with
Context.asType(Class), it returns partial context instance.- Type Parameters:
T- type of the entity- Parameters:
entity- proxied entity- Returns:
- unproxied instance of the entity
-
isUninitialized
public static <T> boolean isUninitialized(T entity) Check whether the given lazy loading proxy instance is uninitialized.- Type Parameters:
T- type of the entity- Parameters:
entity- the lazy loading entity instance- Returns:
- true if uninitialized false otherwise
-