Class EntityInstanceCreator

java.lang.Object
mocka.generator.EntityInstanceCreator

@Component public class EntityInstanceCreator extends Object
EntityInstanceCreator is responsible for creating entity instances through the configured ORMCreator.
It supports multiple ORM implementations and allows instance creation with different GenerateType strategies.

This class is managed as a Spring Component and is typically injected into factories or services that need entity instance generation.

  • Method Details

    • createInstance

      public <T> T createInstance(Class<T> clazz, GenerateType generateType)
      Creates an entity instance for the given class using the default ORM.
      This method should be used when there is only one ORM implementation configured.

      If the GenerateType is ALL, all related entities (both parent and child relationships) are generated recursively. Otherwise, the instance is created according to the specified strategy.

      Type Parameters:
      T - the type of the entity
      Parameters:
      clazz - the class type of the entity to generate
      generateType - the generation strategy (e.g., GenerateType)
      Returns:
      a new instance of the given entity class
    • createInstance

      public <T> T createInstance(ORMType ormType, Class<T> clazz, GenerateType generateType)
      Creates an entity instance for the given class using a specific ORM implementation.
      This method should be used when multiple ORM implementations are configured, and you want to explicitly select which ORMType should be used for entity creation.

      If the GenerateType is ALL, all related entities (both parent and child relationships) are generated recursively. Otherwise, the instance is created according to the specified strategy.

      Type Parameters:
      T - the type of the entity
      Parameters:
      ormType - the ORM implementation type to use
      clazz - the class type of the entity to generate
      generateType - the generation strategy (e.g., SINGLE, CHILD, PARENT, ALL)
      Returns:
      a new instance of the given entity class