-
Type:
Bug
-
Status: Closed
-
Resolution: Fixed
-
Affects Version/s: 7.0.0 DXP FP46, 7.0.X, Master
-
Fix Version/s: 7.0.0 DXP FP50, 7.0.0 DXP SP8, 7.0.X, 7.1.0 Beta 2, 7.1.X, Master
-
Component/s: Core Infrastructure > Service Builder
-
Branch Version/s:7.0.x
-
Backported to Branch:Committed
-
Story Points:12
-
Fix Priority:2
-
Git Pull Request:
Since LPS-29025 there is an extra logic in model_impl.ftl to get the default import locale:
@Override public void prepareLocalizedFieldsForImport() throws LocaleException { Locale defaultLocale = LocaleUtil.fromLanguageId( getDefaultLanguageId()); Locale[] availableLocales = LocaleUtil.fromLanguageIds( getAvailableLanguageIds()); Locale defaultImportLocale = LocalizationUtil.getDefaultImportLocale( ${entity.name}.class.getName(), getPrimaryKey(), defaultLocale, availableLocales); prepareLocalizedFieldsForImport(defaultImportLocale); }
The getPrimaryKey() should return a long value here, but if the entity has a compound index, it will return an entityPK object instead of a long:
@Override public ${entity.PKClassName} getPrimaryKey() { <#if entity.hasCompoundPK()> return new ${entity.PKClassName}( <#list entity.PKList as column> _${column.name} <#if column_has_next> , </#if> </#list> ); <#else> return _${entity.PKList[0].name}; </#if> }
This will cause the generated code to not compile due to :
/Users/vili/workspace/liferay/7.0/liferay-workspace/modules/sb-pk/sb-pk-service/src/main/java/com/liferay/support/poc/sb/model/impl/EmailContentModelImpl.java:490: error: incompatible types: EmailContentPK cannot be converted to long
getPrimaryKey(), defaultLocale, availableLocales);
^
- is duplicated by
-
LPS-81433 If service.xml contains compound primary key, the generated code does not compile
- Closed