VQL中查询对象id
我目前正在使用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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这就是我完成整个往返对象 → OID → 对象的方式:
首先使用
TransSession.getOidAsLong
获取 OID。获得对象 ID 后,只需从其
Handle
中抓取该对象即可。无需 VQL。
This is how I did the whole roundtrip object → OID → object:
First you get the OID with
TransSession.getOidAsLong
.Once you have the object ID, just grab the object from its
Handle
.No VQL needed.
通常键是整数而不是字符串。 您仅使用员工的姓名创建员工,也许正确的标识符是他的员工 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.
你可以尝试这个,
它将返回所有名为“Mr. Pickles”的员工,然后循环遍历它们。
You can try this,
It will return all Employees with the name "Mr. Pickles", Then loop through them.
当然你已经明白了这一点(帖子是几个月前的)。 你想要做的是先使用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);