Package com.axelor.db

Class EntityHelper

java.lang.Object
com.axelor.db.EntityHelper

public final class EntityHelper extends Object
This class provides helper methods for model objects.
  • Constructor Details

    • EntityHelper

      public EntityHelper()
  • Method Details

    • toString

      public static <T extends Model> String toString(T entity)
      The toString helper method.
      Type Parameters:
      T - type of the entity
      Parameters:
      entity - generate toString for the given entity
      Returns:
      string
    • equals

      public static <T extends Model> boolean equals(T entity, Object other)
      The equals helper method.

      This method searches for all the fields marked with EqualsInclude and uses them to check for the equality.

      Type Parameters:
      T - type of the entity
      Parameters:
      entity - the current entity
      other - the other entity
      Returns:
      true if both objects are equal by their fields included for equality check
    • getEntityClass

      public static <T> Class<T> getEntityClass(T entity)
      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