Annotation Type Mapping


@Target({METHOD,PARAMETER,FIELD})
@Retention(RUNTIME)
public @interface Mapping
A mapping to a JPQL expression which contains references to fields of the entity. The Mapping annotation can be applied to abstract getter methods of an interface or abstract class. It may also be applied to constructor parameters. The use of the Mapping annotation is optional for getter methods. If the Mapping annotation is not specified for such a getter, the default values of the Mapping annotation will apply. This means that getter methods are automatically mapped to their attribute names. Example 1: public String getName(); Example 2: @Mapping("UPPER(name)") public String getUpperName(); Example 1 shows a getter which is implicitly mapped to the attribute name which in this case is "name". Example 2 shows that a mapping can contain arbitrary JPQL expressions.
Since:
1.0.0
Author:
Christian Beikov
  • Optional Element Summary

    Optional Elements 
    Modifier and Type Optional Element Description
    FetchStrategy fetch
    The fetch strategy to use for the attribute.
    String[] fetches
    The associations of the entity that should be fetched.
    String value
    The JPQL expression mapping the annotated getter or parameter should map to.
  • Element Details

    • value

      String value
      The JPQL expression mapping the annotated getter or parameter should map to.
      Returns:
      The JPQL expression mapping
      Default:
      ""
    • fetches

      String[] fetches
      The associations of the entity that should be fetched. This is only valid if the mapping refers to an entity and is mapped as attribute with the original type.
      Returns:
      The associations of the entity that should be fetched
      Since:
      1.2.0
      Default:
      {}
    • fetch

      The fetch strategy to use for the attribute.
      Returns:
      The fetch strategy
      Default:
      JOIN