Indicates the execution of associations between entities.
AssociationLinker can be annotated on a field of BiFunction.
For the BiFunction, specify the entity class represented by the propertyPath() as the second type parameter. For the first and third type parameters, specify
the source entity class associated with the entity class given in the second type parameter.
@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 ElementDescriptionSpecifies the property path from the root entity using dot notation.Specifies the table alias for the entity class represented by thepropertyPath().
-
Element Details
-
propertyPath
String propertyPathSpecifies the property path from the root entity using dot notation.For example, suppose the root
Departmentclass has a propertyList<Employee> employeeList, andEmployeehas a propertyAddress address. In this case, the property path representingaddresswould beemployeeList.address.- Returns:
- the property path as a string
-
tableAlias
String tableAliasSpecifies the table alias for the entity class represented by thepropertyPath().For example, consider the following SQL:
SELECT * FROM DEPARTMENT d INNER JOIN EMPLOYEE e ON d.DEPARTMENT_ID = e.DEPARTMENT_ID
In this case, theEmployeeclass corresponds to theEMPLOYEEtable, and its table alias ise.The table alias concatenated with an underscore serves as the prefix for column aliases.
- Returns:
- the table alias as a string
-