PDA

View Full Version : Spring Data Documents: Building typesafe queries / QueryDSL?



ractive
Jun 17th, 2011, 05:08 AM
Hello everyone

I'm currently using mongoTemplate with queries like this one:

Query q= new Query(where("parentId").is(parentId).and("dateTime").gte(start).lt(end));

I'd really like to have a safe way to create such queries, without having to use strings to identify properties (like "dateTime"). I saw that querydsl allows to generate "query types" of annotated entities to avoid such string magic.

Are there similar concepts within spring-data-document? Or is there a way to use the query types or even the queries of querydsl with mongoTemplate?



Best regards,
James

Oliver Gierke
Jun 18th, 2011, 01:26 AM
Currently Querydsl is supported on the repository level only. See [0] for documentation.

[0] http://static.springsource.org/spring-data/data-document/docs/1.0.0.M3/reference/html/#d0e3105

ractive
Jun 19th, 2011, 01:04 PM
Thank you. I'll try it out.

awestwell
Feb 11th, 2012, 01:01 PM
Hey All

Is the QueryDSL still only avaible via the repository if so. What class should I start with to build it up to using in a standard DAO which uses a mongoTemplate?

Thanks