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
- Create a custom query template file.
- Create a WC\config\com.ibm.commerce.servicemodule-ext folder, if one does not already exist.
- 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.
- Click New > Other > Simple > File > Next
- 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.
- Click Finish.
- For a non-associated (single-step) query:
- 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.
- 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.
- Create the query to return the required information.
- For an association query (a two-step query that uses the ASSOCIATION_SQL_STATEMENT block):
- 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.
- Add the custom association SQL template that queries new data (BEGIN_ASSOCIATION_SQL_STATEMENT/END_ASSOCIATION_SQL_STATEMENT).
- Create a new access profile in the profiles section (BEGIN_PROFILE/END_PROFILE) of the custom query template file.
- 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
Related reference
Data service layer naming conventions
WebSphere Commerce extended XPath notation