Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid StackoverflowError when updating entity #18866

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@
<%_ } _%>
<&_ } -&>
<%_ } -%>

<%_ for (const relationship of relationships) { -%>
OmarHawk marked this conversation as resolved.
Show resolved Hide resolved
<&_ if (fragment.relationship<%- relationship.relationshipNameCapitalized %>AnnotationSection) { -&>
<% // just break the cycle // in the reactive area, we already have the annotation in place
if (!relationship.ownerSide && !reactive) { %>
@org.springframework.data.annotation.Transient
<% } %>
<&_ } -&>
<%_ } -%>
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class <%= entityClass %>SearchRepositoryInternalImpl implements <%= entityClass

@Override
public void index(<%= persistClass %> entity) {
repository.find<% if (implementsEagerLoadApis) { %>OneWithEagerRelationships<% } else { %>ById<% } %>(entity.getId()).ifPresent(elasticsearchTemplate::save);
repository.find<% if (implementsEagerLoadApis) { %>OneWithEagerRelationships<% } else { %>ById<% } %>(entity.get<%= primaryKey.nameCapitalized %>()).ifPresent(elasticsearchTemplate::save);
}
}
<%_ } _%>
35 changes: 35 additions & 0 deletions test-integration/samples/jdl-entities/custom-id.jdl
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,38 @@ relationship ManyToMany {

filter UuidIdFiltering, UuidIdFilteringMapsId, UuidIdFilteringRelationship
service UuidIdFiltering, UuidIdFilteringMapsId, UuidIdFilteringRelationship with serviceClass

/*
* Custom named id with required relationships, mapstruct dtos and search
*/
@ChangelogDate(20200804035700)
entity EntityCustomIdRequiredDTO {
@Id customId Long
}

@ChangelogDate(20200804035701)
entity EntityCustomIdRequiredDTOMapsId {
}

@ChangelogDate(20200804035702)
entity EntityCustomIdRequiredDTORel {
@Id relatedId Long
}

relationship OneToOne {
EntityCustomIdRequiredDTOMapsId to @Id EntityCustomIdRequiredDTO
EntityCustomIdRequiredDTORel{oneToOne required} to EntityCustomIdRequiredDTO{oneToOneBack}
EntityCustomIdRequiredDTORel{oneToOneMapsId required} to EntityCustomIdRequiredDTOMapsId{oneToOneMapsIdBack}
}

relationship ManyToOne {
EntityCustomIdRequiredDTORel{manyToOne required} to EntityCustomIdRequiredDTO{manyToOneBack}
EntityCustomIdRequiredDTORel{manyToOneMapsId required} to EntityCustomIdRequiredDTOMapsId{manyToOneMapsIdBack}
}

relationship ManyToMany {
EntityCustomIdRequiredDTORel{manyToMany required} to EntityCustomIdRequiredDTO{manyToManyBack}
EntityCustomIdRequiredDTORel{manyToManyMapsId required} to EntityCustomIdRequiredDTOMapsId{manyToManyMapsIdBack}
}

dto EntityCustomIdRequiredDTO, EntityCustomIdRequiredDTOMapsId, EntityCustomIdRequiredDTORel with mapstruct