“:P” 是什么意思? JDO 查询中的意思

发布于 2024-09-13 19:51:27 字数 644 浏览 9 评论 0原文

我在谷歌应用程序引擎上使用 JDO。每个“员工”都有一把“钥匙”。我有一组密钥,想要检索密钥属于该组的所有员工。

因此,我使用指定的“contains()”过滤器来实现它在这里。代码工作正常,看起来像这样 -

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' 有什么特殊含义吗?

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.

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

百变从容 2024-09-20 19:51:27

我相信它正在映射隐式输入参数。由于只有一个参数,因此不需要显式调用setParameter,直接使用即可。我相信它因为:

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

这可能更清楚。

有关另一个示例,请参阅 Apache JDOQL 文档 的“隐式参数”部分。

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); 

which might be clearer.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文