public EntityJoinHandler<T>
Interface to specify join types for any fields having join annotation:
The join annotations detected by Spring Data Search are the following:
javax.persistence.OneToOne
javax.persistence.OneToMany
javax.persistence.ManyToMany
javax.persistence.ElementCollection
javax.persistence.ManyToOne
It is sometimes useful to optimize the number of SQL queries by specifying the data that you want to fetch during the first SQL query with the criteria.
Here is an example:
/**
* Fetch all fields annotated with @ElementCollection
**/
class MyEntityJoinHandler : EntityJoinHandler {
override fun supports(entityClass: Class<*>, fieldClass: Class<*>, fieldName: String, joinAnnotation: Annotation): Boolean {
return joinAnnotation instanceof ElementCollection;
}
override fun handle(entityClass: Class<*>, fieldClass: Class<*>, fieldName: String, joinAnnotation: Annotation): JoinInfo {
return new JoinInfo(JoinType.LEFT, true);
}
}
boolean supports(@NotNull java.lang.Class<?> entityClass, @NotNull java.lang.Class<?> fieldClass, @NotNull java.lang.String fieldName, @NotNull java.lang.annotation.Annotation joinAnnotation)
Checks if the given arguments are supported by this EntityJoinHandler.
@NotNull JoinInfo handle(@NotNull java.lang.Class<?> entityClass, @NotNull java.lang.Class<?> fieldClass, @NotNull java.lang.String fieldName, @NotNull java.lang.annotation.Annotation joinAnnotation)
Handles the join type for the given arguments.
entityClass
- Class of the Entity beanfieldClass
- Class of the Field present on the EntityfieldName
- Name of the FieldjoinAnnotation
- Join Annotation present on the Entity Fieldclass JoinInfo