Class HibernateFieldValueGenerator

java.lang.Object
mocka.generator.orm.hibernate.HibernateFieldValueGenerator
All Implemented Interfaces:
FieldValueGenerator

@Component public class HibernateFieldValueGenerator extends Object implements FieldValueGenerator
Generates random values for Hibernate entity fields based on their types and JPA annotations.

This generator analyzes field metadata (type, annotations, constraints) and produces appropriate random values for entity instantiation. It supports various data types including primitives, dates, enums, embeddables, and respects JPA validation constraints.

  • Method Details

    • get

      public Object get(Field field)
      Generates a random value for the given field based on its type and annotations.
      Specified by:
      get in interface FieldValueGenerator
      Parameters:
      field - the field to generate a value for
      Returns:
      a randomly generated value appropriate for the field type, or null if the field should not be generated
      Throws:
      RuntimeException - if @Email is used on a non-String field
      UnsupportedOperationException - if the field type is not supported