Custom Finders
If no finderFinderA search specification combining field-operator pairs to execute standard data queries on a DataElement. options are specified, a finderFinderA search specification combining field-operator pairs to execute standard data queries on a DataElement. is expanded based only on its operator pairs with no customization options.
// example for a `findByNameEq` finder
public SearchResult<LocatorData> findByNameEq(ParameterContext<SearchDetails<LocatorFindByNameEqDetails>>
searchParameter) {
SearchDetails < LocatorFindByNameEqDetails > searchDetails = searchParameter.getValue();
LocatorFindByNameEqDetails details = searchDetails.getDetails();
JPAQueryBuilder queryBuilder = createQueryBuilder()
.addParameter(QueryParameter.createStringParameter("name", "LIKE", "Name", details.getName()))
.addSortFields(searchDetails.getSortFields())
;
return fetchData((ParameterContext) searchParameter, queryBuilder);
}
Customizable Finders
A finderFinderA search specification combining field-operator pairs to execute standard data queries on a DataElement. with a finderOption isCustomizableFinder expands fieldOperatorPairs in the same way a plain finderFinderA search specification combining field-operator pairs to execute standard data queries on a DataElement. would,
but includes customization anchorsAnchorA marker within generated source code reserved for adding custom logic during re-expansion. to further manipulate both the query, as well as the fetched data.
// example for `findByStatusSe` with `isCustomizableFinder` option
public SearchResult<LocatorData> findByStatusSe(ParameterContext<SearchDetails<LocatorFindByStatusSeDetails>>
searchParameter) {
SearchDetails < LocatorFindByStatusSeDetails > searchDetails = searchParameter.getValue();
LocatorFindByStatusSeDetails details = searchDetails.getDetails();
JPAQueryBuilder queryBuilder = createQueryBuilder()
.addParameter(QueryParameter.createStringParameter("status", "=", "Status", details.getStatus()))
// anchor:custom-findByStatusSe-query:start
// anchor:custom-findByStatusSe-query:end
;
List<SortField> sortFields = searchDetails.getSortFields();
// anchor:custom-findByStatusSe-sorting:start
// anchor:custom-findByStatusSe-sorting:end
queryBuilder.addSortFields(sortFields);
SearchResult<LocatorData> searchResult = fetchData((ParameterContext) searchParameter, queryBuilder);
// anchor:custom-findByStatusSe-post-fetch:start
// anchor:custom-findByStatusSe-post-fetch:end
return searchResult;
}
FinderAdds additional custom anchorsAnchorA marker within generated source code reserved for adding custom logic during re-expansion. to the find method.
<options>
<isCustomizableFinder/>
</options>
Custom Finders
Finally, a finderFinderA search specification combining field-operator pairs to execute standard data queries on a DataElement. with a finderOption isCustomFinder expands only a shell method to be implemented by developer.
Note that the FinderFinderA search specification combining field-operator pairs to execute standard data queries on a DataElement.'s details class (e.g. LocatorFindByCustomStatusDetails) will still expand accessors for fieldFieldA property of a DataElement expanded to a database column and user interface input element.
operator pairs, if any were defined in the model.
// example for `findByCustomStatus` finder with `isCustomFinder` option and a single `Eq:status` field operator pair.
@SuppressWarnings({"unchecked", "rawtypes"})
public SearchResult<LocatorData> findByCustomStatus(ParameterContext<SearchDetails<LocatorFindByCustomStatusDetails>>
searchParameter) {
SearchDetails < LocatorFindByCustomStatusDetails > searchDetails = searchParameter.getValue();
SearchResult<LocatorData> searchResult = new SearchResult.SearchError<LocatorData>();
//anchor:custom-findByCustomStatus-finder:start
//anchor:custom-findByCustomStatus-finder:end
return searchResult;
}
FinderReplaces finderFinderA search specification combining field-operator pairs to execute standard data queries on a DataElement. implementation with a single custom anchorAnchorA marker within generated source code reserved for adding custom logic during re-expansion..
<options>
<isCustomFinder/>
</options>