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


Configure parametric search to search on custom data

Before new properties can be used as search conditions in a query template, configure parametric search to define the object path mapping so that the query can identify the corresponding column in the database table.

The component configuration file, wc-component.xml, contains a section for the data service layer. It can be divided into 3 main subsections:

When configuring parametric search to search on custom data, provide attribute mapping information. For more detailed reference information, see Parametric search support.


Procedure

  1. Open WebSphere Commerce Developer.

  2. If you have not already done so, create the component configuration file. When you create a custom service module, this file is generated for you, and you can skip this step. However, for default WebSphere Commerce service modules, not directly modify the default wc.component.xml file.

    1. Create a new wc-component.xml file by navigating to the following directory:

      • WC_EAR/xml/config/servicemodulename-ext

      For example, for catalog extensions, you would create the following file:WC_EAR/xml/config/com.ibm.commerce.catalog-ext

    2. Create new XML file in any text or XML editor. Include the following root elements as a template:

      <?xml version="1.0" encoding="UTF-8"?>
      <_config:DevelopmentComponentConfiguration
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-component.xsd "
          xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config"> 
      <!-- Put the custom configuration here --> 
      </_config:DevelopmentComponentConfiguration>
      

  3. Open the component configuration file in any text or XML editor:

    • For custom service modules, open WC_EAR/xml/config/servicemodulename/wc-component.xml

    • For default WebSphere Commerce service modules, open WC_EAR/xml/config/servicemodulename-ext/wc-component.xml

  4. Add object path mappings for the custom data. The following example shows an associated table, XWARRANTY, being defined as associated with the CATENTRY table. Two columns, WARTERM and WARTYPE, are mapped to the UserData area, as UserData/UserDataField/Warterm and UserData/UserDataField/Wartype

    <_config:dataservice dataMediatorType="JDBC" 
                          metadataClass="com.mycompany.commerce.catalog.facade.server.metadata.MyCompanyMetaData">  
    <_config:mapping>    
    <_config:key name="CatalogEntry" />    
    <_config:basetable name="CATENTRY" useAllColumns="false">      
    <_config:associatedtable name="XWARRANTY" useAllColumns="false">        
    <_config:columns name="WARTERM" propertyName="UserData/UserDataField/Warterm" caseSensitive="false" />        
    <_config:columns name="WARTYPE" propertyName="UserData/UserDataField/Wartype" caseSensitive="false" />      
    </_config:associatedtable>    
    </_config:basetable>  
    </_config:mapping>
    </_config:dataservice>
    

  5. Save and close the file. The following example is a sample complete wc-component.xml file:

    <?xml version="1.0" encoding="UTF-8"?>
    <_config:DevelopmentComponentConfiguration
        xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-component.xsd ">     <_config:dataservice dataMediatorType="JDBC"
            metadataClass="com.mycompany.commerce.catalog.facade.server.metadata.MyCompanyMetaData">         
            <_config:mapping>             <_config:key name="CatalogEntry" />             <_config:basetable name="CATENTRY" useAllColumns="false">                 <_config:associatedtable name="XWARRANTY"
                        useAllColumns="false">                     <_config:columns name="WARTERM"
                            propertyName="UserData/UserDataField/Warterm"
                            caseSensitive="false" />                     <_config:columns name="WARTYPE"
                            propertyName="UserData/UserDataField/Wartype"
                                caseSensitive="false" />                 </_config:associatedtable>             </_config:basetable>         </_config:mapping>         
        </_config:dataservice>
    </_config:DevelopmentComponentConfiguration>
    

  6. Restart the WebSphere Commerce server to load the new configuration.


+

Search Tips   |   Advanced Search