Package mocka.generator.orm.hibernate
Class HibernateCreator
java.lang.Object
mocka.generator.orm.AbstractCreator
mocka.generator.orm.hibernate.HibernateCreator
- All Implemented Interfaces:
ORMResolver
Creates and populates Hibernate entity instances with generated data.
This creator handles Hibernate-specific entity creation including:
- Basic field value generation using
HibernateFieldValueGenerator - JPA association handling (OneToMany, ManyToOne, OneToOne, ManyToMany)
- Circular reference prevention through visited path tracking
Collection Size Configuration:
The number of elements generated for collection associations (OneToMany, ManyToMany) is configured throughORMProperties.getAssociationSize().-
Constructor Summary
ConstructorsConstructorDescriptionHibernateCreator(HibernateLoader hibernateLoader, HibernateFieldValueGenerator fieldValueGenerator, 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
-
HibernateCreator
public HibernateCreator(HibernateLoader hibernateLoader, HibernateFieldValueGenerator fieldValueGenerator, 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:
-