File tree 3 files changed +10
-2
lines changed
src/main/java/_package_/_entityPackage_/_partials_entity_ 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -611,6 +611,8 @@ function preparePostEntityCommonDerivedPropertiesNotTyped(entity: any) {
611
611
entity . fields . some ( field => ! field . id && ! field . transient ) ||
612
612
entity . relationships . some ( relationship => ! relationship . id && relationship . persistableRelationship ) ;
613
613
614
+ entity . hasAnyReadonlyField = entity . fields . some ( field => field . readonly && ! ( field . id && field . autoGenerate ) ) ;
615
+
614
616
entity . allReferences
615
617
. filter ( reference => reference . relationship ?. relatedField )
616
618
. forEach ( reference => {
Original file line number Diff line number Diff line change 26
26
< %- mapsIdAssoc .otherEntity .primaryKey .type % > < %- mapsIdAssoc .otherEntityName % > Id = < %- persistInstance % > .get < %- mapsIdAssoc .relationshipNameCapitalized % > ().get < %- mapsIdAssoc .otherEntity .primaryKey .nameCapitalized % > ();
27
27
< %- mapsIdAssoc .otherEntity .entityInstance % > Repository .findById (< %- mapsIdAssoc .otherEntityName % > Id).ifPresent (< %- persistInstance % > :: < % _ if (! fluentMethods) { _% > set< %- mapsIdAssoc .relationshipNameCapitalized % > < % _ } else { _% >< %- mapsIdAssoc .relationshipName % >< % _ } _% > );
28
28
< % _ } _%>
29
- <% - returnDirectly && ! searchEngineElasticsearch && ! dtoMapstruct ? ' return' : ` ${ persistInstance} =` %> <% - entityInstance %> Repository.save(<% - persistInstance %> );
29
+ <% - returnDirectly && ! hasAnyReadonlyField && ! searchEngineElasticsearch && ! dtoMapstruct ? ' return' : ` ${ persistInstance} =` %> <% - entityInstance %> Repository.save<% if (hasAnyReadonlyField && databaseType === ' sql' ) { % > AndFlush< % } %> (<% - persistInstance %> );
30
+ <% _ if (hasAnyReadonlyField) { _% >
31
+ < %- returnDirectly && ! searchEngineElasticsearch && ! dtoMapstruct ? ' return' : ` ${ persistInstance} =` % > < %- entityInstance % > Repository .find < % if (implementsEagerLoadApis) { % > OneWithEagerRelationships< % } else { % > ById< % } % > (< %- persistInstance % > .get < %= primaryKey .nameCapitalized % > ()).orElseThrow ();
32
+ < % _ } _%>
30
33
<% _ if (searchEngineElasticsearch) { _% >
31
34
< %- entityInstance % > SearchRepository .index (< %- persistInstance % > );
32
35
< % _ } _%>
Original file line number Diff line number Diff line change 51
51
return existing< %= entityClass % > ;
52
52
})
53
53
< % _ } % >
54
- .< %= mapOrFlatMap % > (< %= entityInstance % > Repository:: save)
54
+ .< %= mapOrFlatMap % > (< %= entityInstance % > Repository:: save< % if (hasAnyReadonlyField && databaseType === ' sql' ) { % > AndFlush< % } % > )
55
+ < % _ if (hasAnyReadonlyField) { _% >
56
+ .< %= mapOrFlatMap % > ((persistedInstance) - > < %= entityInstance % > Repository .find < % if (implementsEagerLoadApis) { % > OneWithEagerRelationships< % } else { % > ById< % } % > (persistedInstance .get < %= primaryKey .nameCapitalized % > ()).orElseThrow ())
57
+ < % _ } _% >
55
58
< % _ if (searchEngineElasticsearch) { _% >
56
59
.< %= mapOrFlatMap % > (saved< %= entityClass % > - > {
57
60
< % _ if (reactive) { % >
You can’t perform that action at this time.
0 commit comments