Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Hierarchial query problem

441729Aug 4 2005 — edited Aug 5 2005
Hi,

We are trying to convert some old sql code to using Hierarchical queries, but am finding that the connect by expression is causing some errors for us. I have tried to follow the managedEmployees example from the web site but am not getting the parameters set correctly and keep getting the error below. I have attached our old code as well as the new code using Toplink. Please let me know if you see any issues with this.

Also, we have wrapped the Expression and ReadAllQuery classes with our own classes which is why we're not invoking those directly in the code below.

Thanks for the help,
Mark



Old SQL

/*
DataExpression where = new DataExpression().get("organizationId").notNull();
String extraSQL = new String("");
extraSQL += " START WITH organization_id = " + orgId + " ";
extraSQL += " CONNECT BY PRIOR organization_id = parent_id ";
where.appendSQL(extraSQL);
*/

Hierarchical query using Toplink

DataReadAllQuery raq = new DataReadAllQuery(Organization.class);
// Specify a START WITH expression
DataExpression startExpr = new DataExpression().get("organizationId").equal(orgId);
// Specifies a CONNECT BY expression
DataExpression connectBy = new DataExpression().get("organizationId").equal(new DataExpression().get("parentId"));
// Specifies an ORDER SIBLINGS BY vector
Vector order = new Vector();

raq.setHierarchicalQueryClause(startExpr, connectBy, order);
return QueryEngine.readAll(raq);



Error

TopLink Warning]: 2005.08.04 06:28:19.765--ServerSession(16237341)--Exception [TOPLINK-6073] (Oracle TopLink - 10g Developer Preview 3 (10.1.3.0 ) (Build 041116)): oracle.toplink.exceptions.QueryException
Exception Description: Malformed expression in query. Attempting to print an object reference into an SQL statement for query key [
Relation operator =
Query Key organizationId
Base mil.usmc.mol.organization.Organization{DatabaseTable(t0)=DatabaseTable(ORGANIZATIONS)}
Query Key parentId
Base mil.usmc.mol.organization.Organization{DatabaseTable(t0)=DatabaseTable(ORGANIZATIONS)}].
Query: ReadAllQuery(mil.usmc.mol.organization.Organization)
Aug 4, 2005 6:28:19 PM mil.usmc.mol.persistence.QueryEngine executeQuery
SEVERE: Error performing query. Nested exception is:
Exception Description: Malformed expression in query. Attempting to print an object reference into an SQL statement for query key [
Relation operator =
Query Key organizationId
Base mil.usmc.mol.organization.Organization{DatabaseTable(t0)=DatabaseTable(ORGANIZATIONS)}
Query Key parentId
Base mil.usmc.mol.organization.Organization{DatabaseTable(t0)=DatabaseTable(ORGANIZATIONS)}].
Query: ReadAllQuery(mil.usmc.mol.organization.Organization)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 2 2005
Added on Aug 4 2005
3 comments
651 views