本文整理了Java中org.apache.polygene.api.query.Query.iterator
方法的一些代码示例,展示了Query.iterator
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.iterator
方法的具体详情如下:
包路径:org.apache.polygene.api.query.Query
类名称:Query
方法名:iterator
暂无
代码示例来源:origin: apache/attic-polygene-java
private List<ExampleEntity> doList( int howMany )
{
List<ExampleEntity> list = new ArrayList<ExampleEntity>();
UnitOfWork uow = this.unitOfWorkFactory.newUnitOfWork();
Iterator<ExampleEntity> iter = uow.newQuery( this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class ) ).iterator();
int found = 0;
while (iter.hasNext())
{
found++;
ExampleEntity exampleEntity = iter.next();
if (exampleEntity != null)
list.add( exampleEntity );
}
uow.discard();
if (found != howMany)
{
LOG.warn( "Found " + found + " entities instead of " + howMany + "." );
}
return list;
}
代码示例来源:origin: apache/attic-polygene-java
private void doRemove( int howMany )
{
Iterator<ExampleEntity> iter = this.unitOfWorkFactory.currentUnitOfWork().newQuery( this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class )).maxResults( howMany ).iterator();
Integer removed = 0;
while (iter.hasNext())
{
this.unitOfWorkFactory.currentUnitOfWork().remove( iter.next() );
++removed;
}
if (removed != howMany)
{
LOG.warn( "Removed " + removed + " entities instead of " + howMany + "." );
}
}
代码示例来源:origin: apache/attic-polygene-java
@Test
public void whenTraceAllOnCompositeTypeExpectTwoEntryInEntityStore()
throws Exception
{
SomeService2 sc = serviceFinder.findService( SomeService2.class ).get();
assertEquals( 123, sc.doSomethingImportant() );
assertEquals( 456, sc.doSomethingLessImportant() );
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
QueryBuilder<TraceRecord> builder = queryBuilderFactory.newQueryBuilder( TraceRecord.class );
Query<TraceRecord> query = uow.newQuery( builder );
// IS sorting needed??
// TraceRecord template = templateFor( TraceRecord.class );
// query.orderBy( orderBy( template.methodName() ) );
Iterator<TraceRecord> result = query.iterator();
assertTrue( result.hasNext() );
TraceRecord rec1 = result.next();
assertEquals( "doSomethingImportant", rec1.methodName().get() );
assertTrue( result.hasNext() );
TraceRecord rec2 = result.next();
assertEquals( "doSomethingLessImportant", rec2.methodName().get() );
assertFalse( result.hasNext() );
uow.complete();
}
代码示例来源:origin: apache/attic-polygene-java
@Test
public void whenTraceOnMixinTypeMethodExpectOneEntryInEntityStore()
throws Exception
{
SomeService sc = serviceFinder.findService( SomeService.class ).get();
assertEquals( 123, sc.doSomethingImportant() );
assertEquals( 456, sc.doSomethingLessImportant() );
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
QueryBuilder<TraceRecord> builder = queryBuilderFactory.newQueryBuilder( TraceRecord.class );
Query<TraceRecord> query = uow.newQuery( builder );
// IS sorting needed??
// TraceRecord template = templateFor( TraceRecord.class );
// query.orderBy( orderBy( template.methodName() ) );
Iterator<TraceRecord> result = query.iterator();
assertTrue( result.hasNext() );
TraceRecord rec1 = result.next();
assertEquals( "doSomethingImportant", rec1.methodName().get() );
assertFalse( result.hasNext() );
uow.complete();
}
代码示例来源:origin: apache/attic-polygene-java
@Test
public void whenTraceOnConcernExpectOneEntryInEntityStore()
throws Exception
{
// It is not possible to put Annotation on Concern Methods, so it should only record one.
SomeService sc = serviceFinder.findService( SomeService.class ).get();
assertEquals( 123, sc.doSomethingImportant() );
assertEquals( 753, sc.doSomethingInsanelyImportant() );
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
QueryBuilder<TraceRecord> builder = queryBuilderFactory.newQueryBuilder( TraceRecord.class );
Query<TraceRecord> query = uow.newQuery( builder );
// IS sorting needed??
// TraceRecord template = templateFor( TraceRecord.class );
// query.orderBy( orderBy( template.methodName() ) );
Iterator<TraceRecord> result = query.iterator();
assertTrue( result.hasNext() );
TraceRecord rec1 = result.next();
assertEquals( "doSomethingImportant", rec1.methodName().get() );
assertFalse( result.hasNext() );
uow.complete();
}
代码示例来源:origin: apache/attic-polygene-java
assertEquals( TEST_NAME, q.iterator().next().name().get() );
代码示例来源:origin: apache/attic-polygene-java
Iterator<TraceRecord> result = query.iterator();
assertTrue( result.hasNext() );
TraceRecord rec1 = result.next();
代码示例来源:origin: apache/attic-polygene-java
Iterator<Car> cars = query.iterator();
Assert.assertTrue( cars.hasNext() );
Car car1 = cars.next();
内容来源于网络,如有侵权,请联系作者删除!