Spring Data Rest Projections with or without explicit Declaration in Repository -
what difference between creating sdr projection ,
(i) explicitly declaring in corresponding repository in -
@repositoryrestresource(excerptprojection = usersummaryprojection.class) public interface userrepository extends jparepository<user, integer> { .. }
(ii) not explicitly defining projection in repository
what find when projection explicitly declared in repository , projection shown entity wherever findall or findbyid gets called.
but when not declared, there option left either user / not use them so, default fields shown.
some examples -
i find when projection defined, link disappears. example - there userlanguage , reflanguage , say, there 2 repositories userlanguagerepository , resflanguagerepository , there reflangsummaryprojection
userlanguage -> manytoone -> reflanguage reflanguage -> onetomany -> userlanguage
so, going url /userlanguages or /userlanguages/{id} shows embedded data reflanguage field coming out reflangsummaryprojection , link reflang gone. expected dont query generated reflangsummaryproejction still selects columns
projections 2 fold thing:
you create projections enable clients see different views of resource. projections defined interfaces, named , exposed client request parameter. client able choose 1 of registered projections or free choose none of them @ all.
you can elevate 1 of registered projections become excerpt projection (hence attribute name). if declared, automatically used in places related resources appear in representation. default hal format case that's rendered in
_embedded
clause.
Comments
Post a Comment