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 ElementsModifier and TypeRequired ElementDescriptionClass<?>Specifies the root entity class associated with the aggregation strategy.Specifies the root table alias.