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

CacheModel doesn't consider primitive wrapper fields of an entity when generated with ServiceBuilder

    Details

      Description

      History
      https://issues.liferay.com/browse/LPS-9388
      https://issues.liferay.com/browse/LPS-10194
      https://issues.liferay.com/browse/LPS-30281

      Reproduction
      1. Create a sample plugin project
      2. In service.xml add an entity like with a field:

      <column name="fieldX" type="Integer" />

      3. Generate service. Check readExternal and writeExternal methods

      Result: In EntityCacheModel fieldX = objectInput.readInteger(); is created
      Expected: In EntityCacheModel fieldX = (Integer)objectInput.readObject(); is created

      Similar should happen in writeExternal
      Additionally readExternal should throw ClassNotFoundException (if not doing it already)

      Additional info
      The issue will manifest only in case of ints -> Integers because:
      ObjectInput <- DataInput has methods:
      readInt(), readLong, readByte, etc

      And only in the case of ints will a method be generated like:
      readInteger()

      Solution
      LPS-30281 intorduces a new feature to Externalize the CacheModels. Unfortunately currently this does not work with primitive wrappers.

      The issue is similar to LPS-10194, calling isPrimitiveType(false) will be the solution.

      Similar how the primary key field is checked in the ftl file:
      <#if entity.hasPrimitivePK(false)>

      This results in the same call -> isPrimitiveType(false)

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                2 years, 50 weeks, 3 days ago

                Packages

                Version Package
                7.0.0 Beta 6
                Master