bjornharvold
Jul 15th, 2011, 04:38 PM
Here my java class:
Item.java
@Id
private ObjectId id;
private ObjectId categoryId;
Now I want to query on all items matching a categoryId so I use QueryDsl and query like this:
private final QItem item = new QItem("item");
itemRepository.findAll(item.categoryId.eq(new ObjectId("4e20a1f80364a33a365d82ea")));
The query above always returns null;
In mongo, this should equate to:
db.testdb.item.find({"categoryId" : ObjectId("4e20a1f80364a33a365d82ea")}).
This direct mongo query always returns the correct results.
Ideas? Is there a way to print to my slf4j / log4j log and see exactly what the query that's being created by spring-data-mongodb looks like?
Cheers
bjorn
Item.java
@Id
private ObjectId id;
private ObjectId categoryId;
Now I want to query on all items matching a categoryId so I use QueryDsl and query like this:
private final QItem item = new QItem("item");
itemRepository.findAll(item.categoryId.eq(new ObjectId("4e20a1f80364a33a365d82ea")));
The query above always returns null;
In mongo, this should equate to:
db.testdb.item.find({"categoryId" : ObjectId("4e20a1f80364a33a365d82ea")}).
This direct mongo query always returns the correct results.
Ideas? Is there a way to print to my slf4j / log4j log and see exactly what the query that's being created by spring-data-mongodb looks like?
Cheers
bjorn