Annotation Interface AssociationLinker


@Target(FIELD) @Retention(RUNTIME) public @interface AssociationLinker
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 Elements
    Modifier and Type
    Required Element
    Description
    Specifies the property path from the root entity using dot notation.
    Specifies the table alias for the entity class represented by the propertyPath().
  • Element Details

    • propertyPath

      String propertyPath
      Specifies the property path from the root entity using dot notation.

      For example, suppose the root Department class has a property List<Employee> employeeList, and Employee has a property Address address. In this case, the property path representing address would be employeeList.address.

      Returns:
      the property path as a string
    • tableAlias

      String tableAlias
      Specifies the table alias for the entity class represented by the propertyPath().

      For example, consider the following SQL:

       SELECT * FROM DEPARTMENT d INNER JOIN EMPLOYEE e ON d.DEPARTMENT_ID = e.DEPARTMENT_ID
       
      In this case, the Employee class corresponds to the EMPLOYEE table, and its table alias is e.

      The table alias concatenated with an underscore serves as the prefix for column aliases.

      Returns:
      the table alias as a string