Wednesday, July 27, 2011

Service Builder vague behavior

I came across a use case where i have to created Entity with columns which are reserved words in Databases. Initially i didn't observe those are reserved words. If our column name is equal to reserved word service builder tool starts throwing vague errors. I am not able to find where the problem was exactly. My service.xml contains around 20+ tables. Debugging the same sucks & tiresome.

<entity name="MyCustomEntity" table="MyTable" local-service="true" remote-service="false">
        <!-- PK fields -->
        <column name="name" db-name="Name" type="String" primary="true" />

        <!-- Audit fields -->
        <column name="company" db-name="Company" type="String" />
        <column name="default" db-name="Default" type="boolean" />
        <column name="locale" db-name="Locale" type="String" />
        <column name="message" db-name="Message" type="String" />
        <column name="senderAddress" db-name="SenderAddress" type="String" />
        <column name="subject" db-name="Subject" type="String" />
        <column name="type" db-name="Type" type="String" />
        <!-- Order -->
        <order by="desc">
            <order-column name="name" />

If you see above entity portion of my service.xml - the column colored in red is a reserved word that is the one causing the problem.

I have changed that portion to below

        <column name="default_" db-name="Default_" type="boolean" />

If the service builder is behaving in a vague manner & if you are sure about correctness of your entity portion's of service.xml then better have a look at following files
  1. bad_column_names.txt
  2. bad_table_names.txt 
  3. bad_alias_names.txt
Might be some of the column names/alias names/table names are handled separately by Service Builder Tool/Databases.

Please feel free to share your comments. Cheers :)

No comments:

Post a Comment