本文整理了Java中org.apache.polygene.api.query.Query.find
方法的一些代码示例,展示了Query.find
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.find
方法的具体详情如下:
包路径:org.apache.polygene.api.query.Query
类名称:Query
方法名:find
[英]Get the first Entity that matches the criteria. This executes the Query.
[中]获取第一个符合条件的实体。这将执行查询。
代码示例来源:origin: apache/attic-polygene-java
@Override
public void expect()
throws Exception
{
assertThat( query.count(), equalTo(1) );
Male male = query.find();
assertThat( male.title().get(), equalTo( Person.Title.MR ));
}
}
代码示例来源:origin: org.apache.polygene.core/org.apache.polygene.core.testsupport
@Override
public void expect()
throws Exception
{
assertThat( query.count(), equalTo(1) );
Male male = query.find();
assertThat( male.title().get(), equalTo( Person.Title.MR ));
}
}
代码示例来源:origin: org.apache.polygene.core/org.apache.polygene.core.testsupport
@Test
public void script24()
{
final Query<Domain> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Domain.class )
.where( queries.get( "script24" ) ) );
query.setVariable( "domain", "Gaming" );
System.out.println( "*** script24: " + query );
assertThat( query.find().name().get(), is( equalTo( "Gaming" ) ) );
}
}
代码示例来源:origin: apache/attic-polygene-java
@Test
public void script24()
{
final Query<Domain> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Domain.class )
.where( queries.get( "script24" ) ) );
query.setVariable( "domain", "Gaming" );
System.out.println( "*** script24: " + query );
assertThat( query.find().name().get(), is( equalTo( "Gaming" ) ) );
}
}
代码示例来源:origin: org.apache.polygene.core/org.apache.polygene.core.testsupport
@Override
public void expect()
throws Exception
{
assertThat( query.count(), equalTo(1) );
Male male = query.find();
assertThat( male.title().get(), equalTo( Person.Title.MR ));
assertThat( male.name().get(), equalTo( "Joe Doe" ));
}
}
代码示例来源:origin: apache/attic-polygene-java
@Override
public void expect()
throws Exception
{
assertThat( query.count(), equalTo(1) );
Male male = query.find();
assertThat( male.title().get(), equalTo( Person.Title.MR ));
assertThat( male.name().get(), equalTo( "Joe Doe" ));
}
}
代码示例来源:origin: org.apache.polygene.core/org.apache.polygene.core.testsupport
@Test
public void script24()
{
final QueryBuilder<Domain> qb = this.moduleInstance.newQueryBuilder( Domain.class );
final Nameable nameable = templateFor( Nameable.class );
final Query<Domain> query = unitOfWork.newQuery( qb.where( eq( nameable.name(), "Gaming" ) ) );
System.out.println( "*** script24: " + query );
assertThat( query.find().name().get(), is( equalTo( "Gaming" ) ) );
}
代码示例来源:origin: apache/attic-polygene-java
@Test
public void script24()
{
final QueryBuilder<Domain> qb = this.moduleInstance.newQueryBuilder( Domain.class );
final Nameable nameable = templateFor( Nameable.class );
final Query<Domain> query = unitOfWork.newQuery( qb.where( eq( nameable.name(), "Gaming" ) ) );
System.out.println( "*** script24: " + query );
assertThat( query.find().name().get(), is( equalTo( "Gaming" ) ) );
}
代码示例来源:origin: org.apache.polygene.libraries/org.apache.polygene.library.shiro-core
private PasswordSecurable findPasswordSecurable( UnitOfWork uow, String username )
{
QueryBuilder<PasswordSecurable> builder = qbf.newQueryBuilder( PasswordSecurable.class );
builder = builder.where( eq( templateFor( PasswordSecurable.class ).subjectIdentifier(), username ) );
return uow.newQuery( builder ).find();
}
代码示例来源:origin: org.apache.polygene.libraries/org.apache.polygene.library.shiro-core
private RoleAssignee findRoleAssignee( UnitOfWork uow, String username )
{
QueryBuilder<RoleAssignee> builder = qbf.newQueryBuilder( RoleAssignee.class );
builder = builder.where( eq( templateFor( RoleAssignee.class ).subjectIdentifier(), username ) );
return uow.newQuery( builder ).find();
}
}
代码示例来源:origin: apache/attic-polygene-java
private PasswordSecurable findPasswordSecurable( UnitOfWork uow, String username )
{
QueryBuilder<PasswordSecurable> builder = qbf.newQueryBuilder( PasswordSecurable.class );
builder = builder.where( eq( templateFor( PasswordSecurable.class ).subjectIdentifier(), username ) );
return uow.newQuery( builder ).find();
}
代码示例来源:origin: apache/attic-polygene-java
private RoleAssignee findRoleAssignee( UnitOfWork uow, String username )
{
QueryBuilder<RoleAssignee> builder = qbf.newQueryBuilder( RoleAssignee.class );
builder = builder.where( eq( templateFor( RoleAssignee.class ).subjectIdentifier(), username ) );
return uow.newQuery( builder ).find();
}
}
代码示例来源:origin: apache/attic-polygene-java
public Manufacturer findByName( String name )
{
UnitOfWork uow = uowf.currentUnitOfWork();
QueryBuilder<Manufacturer> builder =
module.newQueryBuilder( Manufacturer.class );
Manufacturer template = templateFor( Manufacturer.class );
builder.where( eq( template.name(), name ) );
Query<Manufacturer> query = uow.newQuery( builder);
return query.find();
}
}
代码示例来源:origin: apache/attic-polygene-java
@Override
public User userNamed( String name )
{
return uowf.currentUnitOfWork().newQuery(
qbf.newQueryBuilder( User.class ).where( eq( templateFor( User.class ).name(), name ) )
).find();
}
代码示例来源:origin: apache/attic-polygene-java
public void login( @Name( "name" ) String name, @Name( "password" ) String password )
{
QueryBuilder<User> builder = qbf.newQueryBuilder( User.class )
.where( eq( templateFor( User.class ).name(), name ) );
User user = uowf.currentUnitOfWork()
.newQuery( builder )
.find();
if( user == null || !user.isCorrectPassword( password ) )
{
throw new IllegalArgumentException( "Login incorrect" );
}
}
}
代码示例来源:origin: apache/attic-polygene-java
private ExampleEntity findEntity( String... strings )
{
QueryBuilder<ExampleEntity> builder = this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class );
builder = builder.where( QueryExpressions.containsAll(
QueryExpressions.templateFor( ExampleEntity.class ).strings(),
Arrays.asList( strings ) ) );
return this.unitOfWorkFactory.currentUnitOfWork().newQuery( builder ).find();
}
代码示例来源:origin: apache/attic-polygene-java
@Test
public void testQuery()
throws UnitOfWorkCompletionException
{
// Search for it
try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork() )
{
Query<TestEntity> query = uow.newQuery( queryBuilderFactory.newQueryBuilder( TestEntity.class )
.where( SolrExpressions.search( "hello" ) ) );
TestEntity test = query.find();
Assert.assertThat( test.name().get(), equalTo( "Hello World" ) );
}
}
代码示例来源:origin: apache/attic-polygene-java
private ExampleEntity findEntity( String string )
{
QueryBuilder<ExampleEntity> builder = this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class );
builder = builder.where(
QueryExpressions.contains( QueryExpressions.templateFor( ExampleEntity.class ).strings(), string ) );
return this.unitOfWorkFactory.currentUnitOfWork().newQuery( builder ).find();
}
代码示例来源:origin: apache/attic-polygene-java
@Test
public void givenPlainQueryWhenFindEntityExpectFirstEntityReturned()
{
Query<TestComposite> query = queryBuilderFactory.newQueryBuilder( TestComposite.class ).newQuery( composites );
assertEquals( "A", query.find().a().get() );
assertEquals( 6, query.count() );
}
代码示例来源:origin: apache/attic-polygene-java
private ExampleEntity findEntityBasedOnValueString( String valueString )
{
ValueBuilder<ExampleValue2> vBuilder = this.valueBuilderFactory.newValueBuilder( ExampleValue2.class );
vBuilder.prototype().stringProperty().set( valueString );
ValueBuilder<ExampleValue> vBuilder2 = this.valueBuilderFactory.newValueBuilder( ExampleValue.class );
vBuilder2.prototype().valueProperty().set( vBuilder.newInstance() );
return this.createComplexQuery( vBuilder2.newInstance() ).find();
}
内容来源于网络,如有侵权,请联系作者删除!