Annotation Interface FieldMapping
This annotation is used within RsqlSpec.fieldMappings() to create aliases
for entity fields in RSQL queries. It allows clients to use simpler or more
intuitive names in query strings while mapping them to the actual field names on
the entity.
Example usage:
@GetMapping("/users")
public List<User> search(
@RsqlSpec(
entityClass = User.class,
fieldMappings = {
@FieldMapping(name = "id", field = "userId"),
@FieldMapping(name = "fullName", field = "profile.name")
}
) Specification<User> spec
) {
return userRepository.findAll(spec);
}
In the example above, clients can use id==123 or fullName==John
in their RSQL queries, which will be translated to userId==123 and
profile.name==John respectively.
- See Also:
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhether to allow the use of the original field name in addition to the alias.
-
Element Details
-
name
String nameThe alias name to use in RSQL query strings.This is the name that clients will use when constructing their queries.
- Returns:
- the query parameter field name
-
field
String fieldThe actual field name or path on the entity.This can be a simple field name (e.g.,
"userId") or a nested path using dot notation (e.g.,"profile.name").- Returns:
- the entity field name or path
-
allowOriginalFieldName
boolean allowOriginalFieldNameWhether to allow the use of the original field name in addition to the alias.When
false(default), only the alias name defined inname()can be used in queries. Whentrue, both the alias and the original field name are allowed.- Returns:
trueif the original field name should remain usable,falseto enforce exclusive use of the alias
- Default:
false
-