Package mocka.orm.generator.hibernate
Class HibernateCreator
java.lang.Object
mocka.orm.generator.AbstractORMCreator
mocka.orm.generator.hibernate.HibernateCreator
- All Implemented Interfaces:
Creator,ORMCreator
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) -
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.voidsetAssociationSize(int size) Methods inherited from class mocka.orm.generator.AbstractORMCreator
handleRegexSource, handleValueSource, initInstanceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface mocka.core.generator.Creator
createFromFileSource
-
Constructor Details
-
HibernateCreator
public HibernateCreator(HibernateLoader hibernateLoader, HibernateFieldValueGenerator fieldValueGenerator, ORMProperties ormProperties)
-
-
Method Details
-
create
Creates an entity instance with the specified generation strategy. (exceptGenerateType.ALL- Specified by:
createin interfaceORMCreator- 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 interfaceORMCreator- 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 interfaceORMCreator- Returns:
- a set of all discovered Hibernate entity classes
- See Also:
-
setAssociationSize
public void setAssociationSize(int size)
-