Ok, thanks a lot for this. I agree it should work, but not sure how. I have added it to my local set of changes, and will hopefully be pushed to origin in the weekend.
As for your Jira problems; I don't know why you have a problem. You belong (automatically?) to jira-developers, and for the "QI" project that means you can do "most" stuff. Exclusion is basically "delete" and "security". Are you sure you are logged in (and remain logged in - your name should be visible in the upper right corner)? Cheers On Thu, Jan 7, 2010 at 6:02 PM, Paul MERLIN <[email protected]> wrote: > Hi, > > I came accross something that looks like a bug : I cannot use the Query API > to build a Query using a Where clause on an subtyped Property. > > I get the following exception: > > org.qi4j.runtime.query.QueryException: Unsupported property type:interface > test.SubtypedPropertyQueryTest$Name > at > org.qi4j.runtime.query.grammar.impl.PropertyReferenceImpl.<init>(PropertyReferenceImpl.java:88) > at > org.qi4j.runtime.query.proxy.PropertyReferenceProxy.<init>(PropertyReferenceProxy.java:49) > at > org.qi4j.runtime.query.proxy.MixinTypeProxy.invoke(MixinTypeProxy.java:122) > at test.$Proxy13.name(Unknown Source) > at > test.SubtypedPropertyQueryTest.givenAnEntityWithSubtypedPropertyWhenQueriedOnPropertyThenJustWork(SubtypedPropertyQueryTest.java:94) > > Here is the complete unit test with one first test that query on a legacy > property and pass, the second one that query on a subtyped property and fail. > > public class SubtypedPropertyQueryTest > extends AbstractQi4jTest > { > > public void assemble(ModuleAssembly module) > throws AssemblyException > { > module.addEntities(FlatEntity.class, WoupsEntity.class); > module.addServices(MemoryEntityStoreService.class, > UuidIdentityGeneratorService.class); > new RdfMemoryStoreAssembler().assemble(module); > } > > interface FlatEntity extends EntityComposite > { > Property<String> name(); > } > > interface WoupsEntity extends EntityComposite > { > Name name(); > } > > interface Name extends Property<String> { } > > �...@test > public void > givenAnEntityWithSimplePropertyWhenQueriedOnPropertyThenJustWork() > throws UnitOfWorkCompletionException > { > FlatEntity test; > { > UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(); > EntityBuilder<FlatEntity> builder = > uow.newEntityBuilder(FlatEntity.class); > test = builder.instance(); > test.name().set("Bob"); > test = builder.newInstance(); > uow.complete(); > } > { > UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(); > > QueryBuilder<FlatEntity> queryBuilder = > queryBuilderFactory.newQueryBuilder(FlatEntity.class); > FlatEntity thingTemplate = > QueryExpressions.templateFor(FlatEntity.class); > queryBuilder.where(QueryExpressions.eq(thingTemplate.name(), > "Bob")); > > Query<FlatEntity> query = queryBuilder.newQuery(uow); > query.maxResults(1); > > FlatEntity foundByName = CollectionUtils.firstElementOrNull(query); > Assert.assertEquals("Bob", foundByName.name().get()); > > uow.complete(); > } > } > > // FIXME : This one do not work. > �...@test > public void > givenAnEntityWithSubtypedPropertyWhenQueriedOnPropertyThenJustWork() > throws UnitOfWorkCompletionException > { > WoupsEntity test; > { > UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(); > EntityBuilder<WoupsEntity> builder = > uow.newEntityBuilder(WoupsEntity.class); > test = builder.instance(); > test.name().set("Bob"); > test = builder.newInstance(); > uow.complete(); > } > { > UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(); > > QueryBuilder<WoupsEntity> queryBuilder = > queryBuilderFactory.newQueryBuilder(WoupsEntity.class); > WoupsEntity thingTemplate = > QueryExpressions.templateFor(WoupsEntity.class); > queryBuilder.where(QueryExpressions.eq(thingTemplate.name(), > "Bob")); > > Query<WoupsEntity> query = queryBuilder.newQuery(uow); > query.maxResults(1); > > WoupsEntity foundByName = > CollectionUtils.firstElementOrNull(query); > Assert.assertEquals("Bob", foundByName.name().get()); > > uow.complete(); > } > } > > } > > As subtyping Property is encouraged, I expected queries to work on them. > > Hope this code can help you fix the issue. > > BTW I registered in JIRA and wanted to fill an issue but it seems I do not > have the required credentials. > > > Paul > > > > > _______________________________________________ > qi4j-dev mailing list > [email protected] > http://lists.ops4j.org/mailman/listinfo/qi4j-dev > -- Niclas Hedhman, Software Developer http://www.qi4j.org - New Energy for Java I live here; http://tinyurl.com/2qq9er I work here; http://tinyurl.com/2ymelc I relax here; http://tinyurl.com/2cgsug _______________________________________________ qi4j-dev mailing list [email protected] http://lists.ops4j.org/mailman/listinfo/qi4j-dev

