Search code examples
versant-vod

Query on object id in VQL


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?


Solution

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