什么是“:P”意味着在一个JDO查询中 [英] What does ":P" mean in a JDO query

查看:124
本文介绍了什么是“:P”意味着在一个JDO查询中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在谷歌应用引擎上使用JDO。每个'员工'都有一个'钥匙'。我有一组键,并希望检索所有员工的关键属于这个集合。

I am using JDO on google app engine. Each 'Employee' has a 'key'. I have a set of keys and wanted to retrieve all Employees whose key belongs to this set.

所以我使用'contains()'过滤器来实现它,如此处。代码工作正常,看起来像这样 -

So I implemented it using the 'contains()' filter as specified here. The code works fine and looks like this -

List<Key> keys = getLookupKeys(....) ..//Get keys from somewhere.

Query query = pm.newQuery(Employee.class,":p.contains(key)"); //What is ":P" here?
List<Employee> employees = (List<Employee>) q.execute(keys); //This correctly gives me all I want

所有我想知道的是这是什么:P在这个查询中? Employee对象没有任何名为'p'的字段,我的查询也没有声明任何这样的参数。那么这个'p'指向什么? 'p'有什么特别的意义吗?

All that I wonder is what is this ":P" in this query? The Employee object does not have any field named 'p' neither my query declares any such parameter. So what does this 'p' point to? Does 'p' has any special meaning?

推荐答案

我相信它映射了一个隐含的输入参数。因为只有一个参数,所以你不需要显式调用 setParameter ,你可以使用它。

I believe it's mapping an implicit input parameter. As there's only one parameter, you don't need to explicitly call setParameter, you can just use it. I believe it would have been okay as:

Query query = pm.newQuery(Employee.class,":keys.contains(key)");
List<Employee> employees = (List<Employee>) q.execute(keys); 

可能会更清楚。

请参阅另一个例子是 Apache JDOQL文档中的隐式参数部分。

See the "implicit parameters" part of the Apache JDOQL docs for another example.

这篇关于什么是“:P”意味着在一个JDO查询中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆