Package mocka.generator.orm.mybatis
Class MyBatisCreator
java.lang.Object
mocka.generator.orm.AbstractCreator
mocka.generator.orm.mybatis.MyBatisCreator
- All Implemented Interfaces:
ORMResolver
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 throughORMProperties.getAssociationSize().-
Constructor Summary
ConstructorsConstructorDescriptionMyBatisCreator(MyBatisLoader myBatisLoader, MyBatisFieldValueGenerator fieldValueGenerator, MyBatisMetadata myBatisMetadata, ORMProperties ormProperties, FileSourceCreator fileSourceCreator) -
Method Summary
Modifier and TypeMethodDescription<T> TCreates an entity instance with all associated entity.<T> Tcreate(Class<T> clazz, GenerateType generateType) Creates an entity instance with the specified generation strategy.load()Loads all Hibernate entity classes from the application context.Methods inherited from class mocka.generator.orm.AbstractCreator
handleRegexSource, handleValueSource, initInstance
-
Constructor Details
-
MyBatisCreator
public MyBatisCreator(MyBatisLoader myBatisLoader, MyBatisFieldValueGenerator fieldValueGenerator, MyBatisMetadata myBatisMetadata, ORMProperties ormProperties, FileSourceCreator fileSourceCreator)
-
-
Method Details
-
create
Creates an entity instance with the specified generation strategy. (exceptGenerateType.ALL- Specified by:
createin interfaceORMResolver- Type Parameters:
T- the type of the entity- Parameters:
clazz- the entity class to instantiategenerateType- 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
Creates an entity instance with all associated entity. (GenerateType.ALL)- Specified by:
createin interfaceORMResolver- 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 namevisited- 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
Loads all Hibernate entity classes from the application context.- Specified by:
loadin interfaceORMResolver- Returns:
- a set of all discovered Hibernate entity classes
- See Also:
-