本文整理汇总了Java中com.googlecode.cqengine.resultset.ResultSet.uniqueResult方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.uniqueResult方法的具体用法?Java ResultSet.uniqueResult怎么用?Java ResultSet.uniqueResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.googlecode.cqengine.resultset.ResultSet
的用法示例。
在下文中一共展示了ResultSet.uniqueResult方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeFromIndex
import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
public boolean removeFromIndex(Integer id){
ResultSet<SysUserIndex> resultSet = sysUserData.retrieve(equal(SysUserIndex.ID, id));
if(null != resultSet && resultSet.isNotEmpty()){
SysUserIndex index = resultSet.uniqueResult();
return sysUserData.remove(index);
}
return false;
}
示例2: retrieveOnlyOneVersion
import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
static Car retrieveOnlyOneVersion(IndexedCollection<Car> cars, int carId) {
Query<Car> query = equal(Car.CAR_ID, carId);
ResultSet<Car> multipleCarVersions = cars.retrieve(query);
// Wrap in a result set which will return only one car per version number...
ResultSet<Car> deduplicatedCars = new DeduplicatingResultSet<Car, Integer>(Car.CAR_ID, multipleCarVersions, query, noQueryOptions());
return deduplicatedCars.uniqueResult();
}
示例3: testUniqueResult
import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
/**
* 按单个条件检索
*/
@Test
public void testUniqueResult() throws ExecutionException {
IndexedCollection<Enemy> enemies = manager.get(Enemy.class);
Query<Enemy> query = equal(Enemy_.ID, 10010101L);
ResultSet<Enemy> resultSet = enemies.retrieve(query);
Assert.assertTrue(resultSet.size() == 1);
Enemy enemy = resultSet.uniqueResult();
System.out.println(enemy);
}
示例4: testUniqueResultWithException
import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
/**
* 测试当查询返回值有多个的情况下调用uniqueResult()会抛出异常
*/
@Test(expected = NonUniqueObjectException.class)
public void testUniqueResultWithException() throws ExecutionException {
IndexedCollection<Enemy> enemies = manager.get(Enemy.class);
Query<Enemy> query = greaterThanOrEqualTo(Enemy_.GRADE, 1);
ResultSet<Enemy> resultSet = enemies.retrieve(query);
Assert.assertTrue(resultSet.size() > 1);
Enemy enemy = resultSet.uniqueResult();
System.out.println(enemy);
}