VQL中查询对象id

发布于 2024-07-21 23:09:20 字数 544 浏览 5 评论 0原文

我目前正在使用versant 对象数据库(使用jvi),并且有一个情况需要根据对象id 查询数据库。

问题是我正在使用极点框架对数据库运行一些性能测试,并且该框架中的其中一项测试要求我使用对象引用或低级对象 ID 从数据库中获取对象。 因此,我不允许引用员工对象中的特定字段,但必须对整个对象执行查询。 因此,我不允许“select * from Employee e where e.id = 4”,我需要它来使用整个对象。

我想要实现的目标是然而

Employee employee = new Employee("Mr. Pickles");
session.commit();

FundVQLQuery q = new FundVQLQuery(session, 
                 "select * from Employee employee where employee = $1");
q.bind(employee);
q.execute();

,这会引发 EVJ_NOT_A_VALID_KEY_TYPE 错误。 有谁知道这样做的正确方法?

I'm currently working with the versant object database (using jvi), and have a case where I need to query the database based on an object id.

The problem is I'm running some performance tests on the database using the pole position framework, and one of the tests in that framework requires me to fetch an object from the database using either an object reference or a low level object id. Thus, I'm not allowed to reference specific fields in the employee object, but must perform the query on the object in its entirety. So, it's not allowed for me to go "select * from Employee e where e.id = 4", I need it to use the entire object.

What I'm trying to achieve is something along the lines of

Employee employee = new Employee("Mr. Pickles");
session.commit();

FundVQLQuery q = new FundVQLQuery(session, 
                 "select * from Employee employee where employee = $1");
q.bind(employee);
q.execute();

However, this throws an EVJ_NOT_A_VALID_KEY_TYPE error. Does anyone know the correct way of doing this?

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

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

发布评论

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

评论(4

浪荡不羁 2024-07-28 23:09:21

这就是我完成整个往返对象 → OID → 对象的方式:

首先使用 TransSession.getOidAsLong 获取 OID。

TransSession session = ...;
Employee employee = new Employee("Mr. Pickles");
long oid = TransSession.getOidAsLong(employee);
session.commit();

获得对象 ID 后,只需从其 Handle 中抓取该对象即可。

TransSession session = ...;
Employee employee = (Employee)session.returnHandleFromLong(oid).handleToObject();

无需 VQL。

This is how I did the whole roundtrip object → OID → object:

First you get the OID with TransSession.getOidAsLong.

TransSession session = ...;
Employee employee = new Employee("Mr. Pickles");
long oid = TransSession.getOidAsLong(employee);
session.commit();

Once you have the object ID, just grab the object from its Handle.

TransSession session = ...;
Employee employee = (Employee)session.returnHandleFromLong(oid).handleToObject();

No VQL needed.

橘亓 2024-07-28 23:09:21

通常键是整数而不是字符串。 您仅使用员工的姓名创建员工,也许正确的标识符是他的员工 ID。 我需要更多有关表格的信息才能确定。

Usually keys are integers and not strings. You are creating an Employee using just his name, perhaps the correct identifier to use is his employeeId. I need some more information on the table to know for sure.

望笑 2024-07-28 23:09:21

你可以尝试这个,

FundVQLQuery vql = FundVQLQuery (session, 
   "select selfoid from Employee where name = $1"); 
vql.bind ("Mr. Pickles");
HandleEnumeration e = vql.execute (); 
while ( e.hasmoreHandles() ) {
    Handle handle = e.nexthandle(); 
}

它将返回所有名为“Mr. Pickles”的员工,然后循环遍历它们。

You can try this,

FundVQLQuery vql = FundVQLQuery (session, 
   "select selfoid from Employee where name = $1"); 
vql.bind ("Mr. Pickles");
HandleEnumeration e = vql.execute (); 
while ( e.hasmoreHandles() ) {
    Handle handle = e.nexthandle(); 
}

It will return all Employees with the name "Mr. Pickles", Then loop through them.

空城之時有危險 2024-07-28 23:09:20

当然你已经明白了这一点(帖子是几个月前的)。 你想要做的是先使用GetObjectId,获取对象的VOD Id,然后查询DB;

id = session.GetObjectId(员工);

Sure you figured this out (post was months ago). What you want to do is use the GetObjectId first, to get the VOD Id of the object, then query the DB;

id = session.GetObjectId(employee);

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