Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-34366

Entity's convert-null column is set to blank string when retrieved from cache

    Details

      Description

      I'm using convert null in an entity as follows.

      <entity name="Platform" local-service="true" remote-service="false" cache-enabled="true" >
      		<column name="id" db-name="RECID" type="long" primary="true" />
      		<column name="location" type="String" convert-null="false"/>
      </entity>
      

      When cache is enabled the following happens.

      List<Platform> platforms = platformLocalService.getPlatforms(0, QueryUtil.ALL_POS);
      Platform p1 = platforms.get(0);
      
      List<Platform> cachedPlatforms = platformLocalService.getPlatforms(0, QueryUtil.ALL_POS);
      Platform p2 = cachedPlatforms.get(0);
      
      platformPersistence.clearCache();
      
      List<Platform> freshPlatforms = platformLocalService.getPlatforms(0, QueryUtil.ALL_POS);
      Platform p3 = freshPlatforms.get(0);
      
      System.out.println(String.format("initial: loc: %s", p1.getLocation()));
      System.out.println(String.format("cached: loc: %s", p2.getLocation()));
      System.out.println(String.format("cache cleared: loc: %s", p3.getLocation()));
      

      This produces following output
      > initial: null
      > cached:
      > fresh: null

      It seems that when object is returned from cache the convert-null=false behavior is not respected and null is converted to empty string.

      I would assume that caching an entity should not change it's data so there might be a bug somewhere.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                6 years, 23 weeks, 4 days ago

                Packages

                Version Package