Skip to content

Commit

Permalink
fix the data type issue when primary key is a custom type
Browse files Browse the repository at this point in the history
fix for issue greenrobot#1051
When primary key is a custom type, the generated code for updateKeyAfterInsert and getKey will return String but the actual primary key is not.
  • Loading branch information
passos authored Aug 6, 2020
1 parent 0cce6c0 commit aa840aa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DaoGenerator/src-template/dao.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ as property>\"${property.dbName}\"<#if (index.propertiesOrder[property_index])??
</#if>
return rowId;
<#else>
return entity.get${entity.pkProperty.propertyName?cap_first}();
return (${entity.pkType}) entity.get${entity.pkProperty.propertyName?cap_first}();
</#if>
<#else>
// Unsupported or missing PK type
Expand All @@ -257,7 +257,7 @@ as property>\"${property.dbName}\"<#if (index.propertiesOrder[property_index])??
public ${entity.pkType} getKey(${entity.className} entity) {
<#if entity.pkProperty??>
if(entity != null) {
return entity.get${entity.pkProperty.propertyName?cap_first}();
return (${entity.pkType}) entity.get${entity.pkProperty.propertyName?cap_first}();
} else {
return null;
}
Expand Down

0 comments on commit aa840aa

Please sign in to comment.