本文整理汇总了Java中org.apache.deltaspike.data.api.criteria.Criteria.getResultList方法的典型用法代码示例。如果您正苦于以下问题:Java Criteria.getResultList方法的具体用法?Java Criteria.getResultList怎么用?Java Criteria.getResultList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.deltaspike.data.api.criteria.Criteria
的用法示例。
在下文中一共展示了Criteria.getResultList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldFindCarByMultipleExampleCriteria
import org.apache.deltaspike.data.api.criteria.Criteria; //导入方法依赖的package包/类
@Test
@DataSet("cars-full.yml")
public void shouldFindCarByMultipleExampleCriteria() {
Car carExample = new Car().model("SE");
SalesPoint salesPoint = new SalesPoint(new SalesPointPK(2L, 1L));
List<SalesPoint> salesPoints = new ArrayList<>();
salesPoints.add(salesPoint);
carExample.setSalesPoints(salesPoints);
Brand brand = new Brand(2L);
carExample.setBrand(brand);//model SE, brand: Nissan, salesPint: Nissan Sales
Criteria<Car,Car> criteriaByExample = carService.example(carExample, Car_.model, Car_.brand,Car_.salesPoints);
assertThat(carService.count(criteriaByExample).intValue()).isEqualTo(1);
List<Car> carsFound = criteriaByExample.getResultList();
assertThat(carsFound).isNotNull().hasSize(1)
.extracting("name")
.contains("Sentra");
}
示例2: shouldFindCarByExampleUsingAnExistingCriteria
import org.apache.deltaspike.data.api.criteria.Criteria; //导入方法依赖的package包/类
@Test
@DataSet("cars-full.yml")
public void shouldFindCarByExampleUsingAnExistingCriteria() {
Criteria<Car,Car> criteria = crudService.criteria()
.join(Car_.brand,carService.where(Brand.class)
.eq(Brand_.name,"Nissan")
); //cars with brand nissan
Car carExample = new Car().model("SE");
//will add a restriction by car 'model' using example criteria
Criteria<Car,Car> criteriaByExample = carService.example(criteria,carExample, Car_.model);
criteriaByExample = carService.example(criteriaByExample,carExample,Car_.salesPoints);
assertThat(carService.count(criteriaByExample).intValue()).isEqualTo(1);
List<Car> carsFound = criteriaByExample.getResultList();
assertThat(carsFound).isNotNull().hasSize(1)
.extracting("name")
.contains("Sentra");
}