-
Type:
Bug
-
Status: Closed
-
Resolution: Fixed
-
Affects Version/s: 6.2.10 EE GA1, 6.2.X EE, 7.0.0 Beta 5
-
Fix Version/s: 7.0.0 Beta 6, Master
-
Component/s: Core Infrastructure > Service Builder
-
Labels:
-
Story Points:1.5
-
Fix Priority:4
-
Git Pull Request:
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)