Annotation Type Link


  • @Target(FIELD)
    @Retention(RUNTIME)
    @Documented
    public @interface Link
    Mark a soft reference (contextId) field as linked to another repository domain class. Doing so facilitates fetch criteria targeting fields from the related domain that were hydrated into a projection. This is a query optimization and allows criteria to extend into the related domain. This does not, however, facilitate fetch hydration of those related fields into the projection. That hydration step is still primarily performed via HydrationUtility.

    Link is always used in combination with FilterAndSortAlias. @FilterAndSortAlias provides the mapping to the property in the projection that contains the richer structure that is hydrated with filterable properties referencing this linked entity. For example, CategoryProduct contains this structure:

       public class CategoryProduct implements Serializable, ContextStateAware, Sorted {
       ...
       private ProductRef product;
       ...
       }
     
    In this case, the product field contains the ProductRef structure, which is a semi-rich representation of Product. As a result, it may be that filter criteria is requested against fields in ProductRef. The @Link and @FilterAndSortAlias annotations would therefore look like the following in JpaCategoryProduct:
         public class JpaCategoryProduct implements Serializable,
             Trackable, ModelMapperMappable, BusinessTypeAware, Sortable {
         ...
         @Indexed
         @Link(value = JpaProduct.class)
         @FilterAndSortAlias("product")
         private String productContextId;
         ...
         }
     
    Author:
    Jeff Fischer
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      Class<?> value
      The type of the target repository domain.
    • Element Detail

      • value

        Class<?> value
        The type of the target repository domain. This is the domain type of the entity whose contextId matches that of the soft reference field annotated with Link.
        Returns:
        The type of the target repository domain