Liferay.com

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" />
        </order>       
    </entity>

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 :)

Friday, July 22, 2011

Entity caching disabling - custom portlet

In some cases we need to disable caching for some Entities in Liferay according to requirements. In one of my project i got a requirement where i got this use case for my plugin portlet


By default Liferay caches all the entities.

First Option : One way to do it is, at entity level in service.xml set cache-enabled attribute to false as below

    <entity name="MyModelEntity" table="MyModelEntity" local-service="true" remote-service="true" cache-enabled="false">

Second option:  You can disable the same @ portlet level by setting following properties, in your portal.properties underr src folder of your portlet plugin add following porperties (I am not pretty much sure about below one)

value.object.entity.cache.enabled.com.xyz.abc.common.model.MyModelEntity=false;
value.object.finder.cache.enabled.com.xyz.abc.common.model.MyModelEntity=false;

Colored in blue is path to your model entity

I hope it will helpful for some who is looking for similar stuff.

Please feel free to drop your comments