本文整理汇总了Java中org.springframework.data.querydsl.binding.QuerydslPredicate类的典型用法代码示例。如果您正苦于以下问题:Java QuerydslPredicate类的具体用法?Java QuerydslPredicate怎么用?Java QuerydslPredicate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QuerydslPredicate类属于org.springframework.data.querydsl.binding包,在下文中一共展示了QuerydslPredicate类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: extractTypeInfo
import org.springframework.data.querydsl.binding.QuerydslPredicate; //导入依赖的package包/类
/**
* Obtains the domain type information from the given method parameter. Will
* favor an explicitly registered on through
* {@link QuerydslPredicate#root()} but use the actual type of the method's
* return type as fallback.
*
* @param parameter
* must not be {@literal null}.
* @return
*/
static TypeInformation<?> extractTypeInfo(MethodParameter parameter) {
QuerydslPredicate annotation = parameter.getParameterAnnotation(QuerydslPredicate.class);
if (annotation != null && !Object.class.equals(annotation.root())) {
return ClassTypeInformation.from(annotation.root());
}
Class<?> containingClass = parameter.getContainingClass();
if (ClassUtils.isAssignable(EntityController.class, containingClass)) {
ResolvableType resolvableType = ResolvableType.forClass(containingClass);
return ClassTypeInformation.from(resolvableType.as(EntityController.class).getGeneric(0).resolve());
}
return detectDomainType(ClassTypeInformation.fromReturnTypeOf(parameter.getMethod()));
}
开发者ID:xiangxik,项目名称:java-platform,代码行数:27,代码来源:DefaultPredicateArgumentResolver.java
示例2: index
import org.springframework.data.querydsl.binding.QuerydslPredicate; //导入依赖的package包/类
@RequestMapping(value = "/", method = RequestMethod.GET)
String index(Model model, //
@QuerydslPredicate(root = User.class) Predicate predicate, //
@PageableDefault(sort = { "lastname", "firstname" }) Pageable pageable, //
@RequestParam MultiValueMap<String, String> parameters) {
ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromCurrentRequest();
builder.replaceQueryParam("page", new Object[0]);
model.addAttribute("baseUri", builder.build().toUri());
model.addAttribute("users", repository.findAll(predicate, pageable));
return "index";
}
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:15,代码来源:UserController.java
示例3: findDishes
import org.springframework.data.querydsl.binding.QuerydslPredicate; //导入依赖的package包/类
@RequestMapping(value = "search", method = RequestMethod.GET)
public ModelAndView findDishes(@QuerydslPredicate(root = Dish.class) Predicate predicate, @PageableDefault(sort = {"date"}, direction = Sort.Direction.DESC) Pageable pageable, ModelAndView modelAndView) {
Sort realSort = pageable.getSort().and(new Sort(Sort.Direction.ASC, "id"));
PageRequest pageRequest = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), realSort);
Page<Dish> page = dishRepo.findAll(predicate, pageRequest);
List<DishWebDTO> dishes = page.getContent().stream().map(dishDtoFactory::create).collect(Collectors.toList());
modelAndView.addObject("page", page);
modelAndView.addObject("dishes", dishes);
modelAndView.addObject("labels", getLabelsFromDishes());
modelAndView.addObject("categories", getCategoriesFromDishes());
modelAndView.addObject("mensas", mensaRepo.findAllByOrderByName());
modelAndView.setViewName("search");
return modelAndView;
}
开发者ID:xabgesagtx,项目名称:mensa-api,代码行数:15,代码来源:MensaWebController.java
示例4: getPatientsByPredicate
import org.springframework.data.querydsl.binding.QuerydslPredicate; //导入依赖的package包/类
/**
* Another alternative to QBE via QueryDsl Predicates.
*
* @param predicate the Predicate to use to query with
* @param pageable a Pageable to restrict results
* @return A paged result of matching Patients
*/
@GetMapping("/search/predicate")
public Page<Patient> getPatientsByPredicate(
@QuerydslPredicate(root = Patient.class) final Predicate predicate,
@PageableDefault(size = DEFAULT_PAGE_SZ) final Pageable pageable) {
Page<Patient> pagedResults = this.patientRepository.findAll(predicate, pageable);
if (!pagedResults.hasContent()) {
throw new NotFoundException(Patient.RESOURCE_PATH,
"No Patients found matching predicate " + predicate);
}
return pagedResults;
}
开发者ID:ssherwood,项目名称:spring-boot-jpa,代码行数:21,代码来源:PatientController.java
示例5: supportsParameter
import org.springframework.data.querydsl.binding.QuerydslPredicate; //导入依赖的package包/类
@Override
public boolean supportsParameter(MethodParameter parameter) {
if (Predicate.class.equals(parameter.getParameterType())) {
return true;
}
if (parameter.hasParameterAnnotation(QuerydslPredicate.class)) {
throw new IllegalArgumentException(
String.format("Parameter at position %s must be of type Predicate but was %s.",
parameter.getParameterIndex(), parameter.getParameterType()));
}
return false;
}
开发者ID:xiangxik,项目名称:java-platform,代码行数:16,代码来源:DefaultPredicateArgumentResolver.java
示例6: find
import org.springframework.data.querydsl.binding.QuerydslPredicate; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.GET, value = "/cust")
public Iterable<Customer> find(@QuerydslPredicate(root = Customer.class) Predicate predicate, Pageable pageable,
@RequestParam MultiValueMap<String, String> parameters) {
System.out.println();
System.out.println(predicate);
System.out.println();
return customerRepository.findAll(predicate, pageable);
}
开发者ID:Nandtel,项目名称:spring-data-jpa-querydsl-gradle-starter,代码行数:11,代码来源:Application.java
注:本文中的org.springframework.data.querydsl.binding.QuerydslPredicate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论