开发者

Rounding a value in JDOQL

I've got data in the GAE data store. I want to write a JDOQL against that data that takes one of the columns and rounds the 开发者_开发技巧value of it. Can I do this?


do you mean, can you update the data in the datastore to have the rounded value? if so, sure. just query for them, update that property, and store them back in the datastore.

if you mean, can you write a query that filters based on the rounded value instead of the real value, then also yes. you'd just adjust your queries and filter values. for example, if you want all entities with a rounded value >= 5, you'd use 4.5 as the filter value:

Query query = pm.newQuery(Foo.class, "property >= 4.5");

if you want all entities with a rounded value of 5 exactly, you'd query for everything between 4.5 and 5.5:

Query query = pm.newQuery(Foo.class, "property >= 4.5 && property < 5.5");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜