You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
org.springframework.data.web.PagedModel was introduced in 3.3 via #3024 as a middle ground between serializing PageImpl directly and adopting Spring HATEOAS. There is currently no equivalent for Slice.
Problem
The rationale in #3024 applies equally to slices. SliceImpl is a domain type, so its JSON representation carries the same stability risk that motivated PagedModel — but returning a Slice from a controller today leaves three options, none good:
Serialize SliceImpl as-is, with the same instability PagedModel exists to avoid (and without the PlainPageSerializationWarning that flags the problem for pages).
org.springframework.data.web.PagedModelwas introduced in 3.3 via #3024 as a middle ground between serializingPageImpldirectly and adopting Spring HATEOAS. There is currently no equivalent forSlice.Problem
The rationale in #3024 applies equally to slices.
SliceImplis a domain type, so its JSON representation carries the same stability risk that motivatedPagedModel— but returning aSlicefrom a controller today leaves three options, none good:SliceImplas-is, with the same instabilityPagedModelexists to avoid (and without thePlainPageSerializationWarningthat flags the problem for pages).SlicedResourcesAssembler(Support to renderSlicedModelfromSlicevia a dedicatedRepresentationModelAssembler#1307), which is the documented answer but changes the payload to HAL.SlicedModelDTO per project.Proposal
A
SlicedModel<T>inorg.springframework.data.web, mirroringPagedModelin shape and usage:{ "content": [ ... ], "page": { "size": 20, "number": 0, "numberOfElements": 20, "hasNext": true } }Deliberately no
totalElements/totalPages, since that information is exactly what aSlicedoes not have.