Skip to content

Commit

Permalink
adjusts
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Jan 25, 2024
1 parent 86f0938 commit 197a3d1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
5 changes: 4 additions & 1 deletion generators/base-application/support/prepare-entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export function prepareEntityPrimaryKeyForTemplates(
) {
const idFields = entityWithConfig.fields.filter(field => field.id);
const idRelationships = entityWithConfig.relationships.filter(relationship => relationship.id);
let idCount = idFields.length + idRelationships.length;
let idCount = idFields.length + idRelationships.length;

if (idCount === 0) {
let idField = entityWithConfig.fields.find(field => field.fieldName === 'id');
Expand Down Expand Up @@ -352,6 +352,9 @@ export function prepareEntityPrimaryKeyForTemplates(
get fieldName() {
return idCount === 1 ? field.fieldName : `${relationship.relationshipName}${field.fieldNameCapitalized}`;
},
get fieldType() {
return field.fieldType;
},
get fieldNameCapitalized() {
return idCount === 1
? field.fieldNameCapitalized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ _%>
<%_ if (property.fieldTypeBytes && databaseTypeSql) { _%>
@Lob
<%_ } _%>
<%_ if (property.collection && relationship) { _%>
private Set<<%= relationship.otherEntity.dtoClass %>> <%= property.propertyName %> = new HashSet<>();
<%_ } else { _%>
private <%= property.propertyDtoJavaType %> <%= property.propertyName %>;
<%_ } _%>
private <%= property.propertyDtoJavaType %> <%= property.propertyName %><% if (property.collection && relationship) { %> = new HashSet<>()<% } %>;
<%_ if (property.fieldWithContentType) { _%>
private String <%= property.propertyName %>ContentType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ package <%= entityAbsolutePackage %>.service.mapper;
<%_
const getOriginalField = field => field.originalField || field;
const uuidMapMethod = dtoReferences.some(reference => reference.valueReference && reference.valueReference.field && reference.valueReference.field.fieldTypeUUID);
const byteMapMethod = dtoReferences.some(reference => reference.valueReference && reference.valueReference.field && reference.valueReference.field.fieldTypeBytes);
const dtoRelationships = dtoReferences.filter(reference => reference.relationship && !reference.relationship.otherEntity.embedded).map(reference => reference.relationship);
const uuidMapMethod = restProperties.some(property => property.relatedField?.fieldTypeUUID);
const byteMapMethod = restProperties.some(property => property.relatedField?.fieldTypeBytes);
const dtoRelationships = restProperties.filter(property => property.relationshipName && !relationship.otherEntity.embedded);
let otherEntitiesFields = otherEntities
.filter(otherEntity => dtoRelationships.some(relationship => relationship.otherEntity === otherEntity))
.map(otherEntity =>
Expand Down

0 comments on commit 197a3d1

Please sign in to comment.