Annotation Interface AggregateStrategy


@Target(TYPE) @Retention(RUNTIME) public @interface AggregateStrategy
Indicates a strategy for aggregating database records into hierarchical entity structures.

This annotation enables mapping of relational query results to complex object graphs with parent-child relationships.

The element annotated with AggregateStrategy must be an interface.

 @AggregateStrategy(root = Department.class, tableAlias = "d")
 interface DepartmentStrategy {

     @AssociationLinker(propertyPath = "employeeList", tableAlias = "e")
     BiFunction<Department, Employee, Department> employeeList = (d, e) -> {
         d.getEmployeeList().add(e);
         e.setDepartment(d);
         return d;
     };

     @AssociationLinker(propertyPath = "employeeList.address", tableAlias = "a")
     BiFunction<Employee, Address, Employee> employeeListAddress = (e, a) -> {
         e.setAddress(a);
         return e;
     };
 }
 
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Specifies the root entity class associated with the aggregation strategy.
    Specifies the root table alias.
  • Element Details

    • root

      Class<?> root
      Specifies the root entity class associated with the aggregation strategy.
      Returns:
      the root class
    • tableAlias

      String tableAlias
      Specifies the root table alias.
      Returns:
      the alias name for a root table