Develop > Business logic layer > Work with the data service layer > Create a query


Create an access profile for an existing XPath expression

A new access profile is required when return different data for a noun than is returned by the default access profiles. If you have extended the WebSphere Commerce schema with custom tables, and need to return data from the custom tables, create a new access profile.


Before you begin

Define the XPath expression.


Procedure

  1. Create a custom query template file.

    1. Create a WC\config\com.ibm.commerce.servicemodule-ext folder, if one does not already exist.

    2. Right-click the WC\config\com.ibm.commerce.servicemodule-ext folder. Create the folder in the -ext directory. Do not modify WebSphere Commerce query templates directly.

    3. Click New > Other > Simple > File > Next

    4. Name the custom query template file, using some unique string (your company name) to differentiate it: wc-query-MyCompanyCatalogEntry-get.tpl. Prefix the template file with wc-query.

    5. Click Finish.

  2. For a non-associated (single-step) query:

    1. Define the column definitions to be used in the select list of the custom XPath to SQL template in the symbol definition section of the custom query template file.

    2. Create a new XPATH_TO_SQL_STATEMENT block in the query template file. The name of the query is the XPath key + access profile name.

    3. Create the query to return the required information.

  3. For an association query (a two-step query that uses the ASSOCIATION_SQL_STATEMENT block):

    1. Define the column definitions to be used in the select list of the custom association SQL template in the symbol definition section of the custom query template file.

    2. Add the custom association SQL template that queries new data (BEGIN_ASSOCIATION_SQL_STATEMENT/END_ASSOCIATION_SQL_STATEMENT).

    3. Create a new access profile in the profiles section (BEGIN_PROFILE/END_PROFILE) of the custom query template file.

    4. Add the name of the custom association SQLs to the new access profile definition


What to do next

If you find the performance on single step queries is not satisfactory due to table joins, divide the query into multiple associated SQL statements. In this case, you might need to implement the own Graph composer, if the result sets of the association SQL statements retrieve identical records from tables other than the base table.


Related concepts

Data service layer

Access profiles

Query template file

Related reference

SQL parameters

Query template file tags

Data service layer naming conventions

WebSphere Commerce extended XPath notation


+

Search Tips   |   Advanced Search