google-code-export / morphia

Automatically exported from code.google.com/p/morphia
1 stars 0 forks source link

Support for (compile-time) typesafe queries #399

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice if we could query type safe.

For example, in  http://code.google.com/p/morphia/wiki/Query it would be nice 
if we could make sure that the field foo actually exists in `MyEntity.class` 
and that operations expressed in the query are compatible with this type. This 
will probably involve some code generetion to generate a class like 
`MyEntityField` that has a field FOO and legitimate operations.

Some one can write:
{{{
ds.createQuery(MyEntity.class).filter(MyEntityField.FOO.lessThan(12)).offset(100
0);
}}}
instead of:
{{{
ds.createQuery(MyEntity.class).filter("foo >", 12).offset(1000);
}}}

Any thoughts on this?

Original issue reported on code.google.com by wouter...@gmail.com on 28 Mar 2012 at 8:30

GoogleCodeExporter commented 9 years ago
You can use QueryDSL to do this already. I don't see this being done in morphia 
when there are already projects which do this which integrate. 
http://blog.mysema.com/search/label/morphia

Morphia already checks for the fields and types at runtime when you use the 
second form.

Original comment by scotthernandez on 28 Mar 2012 at 12:37

GoogleCodeExporter commented 9 years ago
I was unaware that QueryDSL was morphia compatible for mongoDB. Thanks!

Original comment by wouter...@gmail.com on 28 Mar 2012 at 12:50