the typical thing in SQL where you filter by matching a column from the result of another query:
1 2 3 4 5 6 | SELECT column_name [, column_name ] FROM table1 [, table2 ] WHERE column_name OPERATOR ( SELECT column_name [, column_name ] FROM table1 [, table2 ] [ WHERE ]) |
This in ATG can be done using a query builder operation called: createIncludesItemQuery. You can pass as parameter another query and the colum matching expression.
1 2 3 4 5 6 7 8 9 10 11 12 | // Get guide items where tabs in the guide matches some other tabs query RepositoryItemDescriptor guideRepositoryItemDescriptor = getProductRepository().getItemDescriptor( "guide" ); RepositoryView guidesRepositoryView = guideRepositoryItemDescriptor.getRepositoryView(); QueryBuilder guidesQueryBuilder = guidesRepositoryView.getQueryBuilder(); QueryExpression tabsPropertyExpression = guidesQueryBuilder.createPropertyQueryExpression( "tabs" ); // productTabsQuery is another query built Query productGuidesQuery = guidesQueryBuilder.createIncludesItemQuery(tabsPropertyExpression, productTabsQuery); RepositoryItem[] guides = guidesRepositoryView.executeQuery(productGuidesQuery); |
No comments:
Post a Comment