Hi,

I had a need for a new Query API operator, which works as follows: if you have an entity with a ManyAssociation, you may want to find all entities where the ManyAssociation contains a specific entity. In my own case I had a UserEntity with a ManyAssociation<Organization> for the organizations the user is a member of. Then I wanted to find all users for a particular organization.

This can be done using the new QueryExpressions.contains(ManyAssociation, entity) operator. I have added a new testcase for it in RdfQueryTest, which looks like this:
QueryBuilder<Person> qb = qbf.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Domain gaming = unitOfWork.get( Domain.class, "Gaming" );
Query<Person> query = qb.where(
    contains( person.interests(), gaming)
).newQuery( unitOfWork );
System.out.println( "*** script33: " + query );

verifyUnorderedResults( query, "Joe Doe" );
---
In this case it finds all people whose interests() ManyAssociation contains the entity with id "Gaming".

I've added this to Iterable queries as well.

/Rickard

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to