PDA

View Full Version : Using QueryDsl to query on collections



bjornharvold
Aug 25th, 2011, 03:20 PM
I am having problems with using QueryDsl.

I have some code in a test of mine below. When I use query dsl, I get nothing back. When I use a regular query, I get back what I expect.



page = itemRepository.findAll(new PageRequest(0, 1));
List<ObjectId> categoryIds = new ArrayList<ObjectId>();
ObjectId categoryId = page.getContent().get(0).getCtds().get(0);
categoryIds.add(categoryId);

page = itemRepository.findAll(QItem.item.ctds.in(category Ids), new PageRequest(i, 2));
List<Item> list = mongoTemplate.find(query(where("ctds").in(categoryIds.toArray())), Item.class);
assertNotNull("page is null", page);
assertNotNull("list is null", list);


Ideas?

Oliver Gierke
Aug 28th, 2011, 01:13 PM
Have you tried lowering the log level and comparing the queries?

timowest
Aug 29th, 2011, 02:04 AM
How does the Item class look like?

bjornharvold
Aug 30th, 2011, 11:34 AM
@oliver, when I lower the logging level, the query dsl method produces no logging output. (log4j appender is on org.springframework.data). The query method does produce logging output as expected.

@tim,

Item.java {
private List<ObjectId> ctds;
}

timowest
Aug 31st, 2011, 04:09 AM
The issue has been fixed now in Querydsl : https://bugs.launchpad.net/querydsl/+bug/837934

bjornharvold
Aug 31st, 2011, 09:20 AM
Great news. Thanks so much.