Class MyBatisCreator

java.lang.Object
mocka.orm.generator.AbstractORMCreator
mocka.orm.generator.mybatis.MyBatisCreator
All Implemented Interfaces:
Creator, ORMCreator

@Component public class MyBatisCreator extends AbstractORMCreator implements ORMCreator
Creates and populates MyBatis entity instances with generated data. This creator handles MyBatis-specific entity creation including:
  • Basic field value generation using MyBatisFieldValueGenerator
  • xml association handling
  • Circular reference prevention through visited path tracking

Collection Size Configuration:

The number of elements generated for collection associations is configured through ORMProperties.getAssociationSize().
See Also:
  • Constructor Details

  • Method Details

    • create

      public <T> T create(Class<T> clazz, GenerateType generateType)
      Creates an entity instance with the specified generation strategy. (except GenerateType.ALL
      Specified by:
      create in interface ORMCreator
      Type Parameters:
      T - the type of the entity
      Parameters:
      clazz - the entity class to instantiate
      generateType - the generation strategy determining which associations to populate
      Returns:
      a new entity instance with populated fields
      Throws:
      RuntimeException - if entity instantiation or field access fails
      See Also:
    • create

      public <T> T create(Class<T> clazz, Map<String,Object> caches, Set<VisitedPath> visited)
      Creates an entity instance with all associated entity. (GenerateType.ALL)
      Specified by:
      create in interface ORMCreator
      Type Parameters:
      T - the type of the entity
      Parameters:
      clazz - the entity class to instantiate (starting point)
      caches - a cache map storing created instances by class name
      visited - a set tracking visited relationship paths to prevent circular references
      Returns:
      a new entity instance with the entire relationship graph populated
      Throws:
      RuntimeException - if entity instantiation or field access fails
      See Also:
    • load

      public Set<Class<?>> load()
      Loads all Hibernate entity classes from the application context.
      Specified by:
      load in interface ORMCreator
      Returns:
      a set of all discovered Hibernate entity classes
      See Also:
    • setAssociationSize

      public void setAssociationSize(int size)