简体   繁体   中英

Spring REST fetching related entities

I'm Django developer and I wanna try Java and Spring. Can somebody guide me, I have entity SomeModel and it's related as many to one RelatedModel. So my problem is returning the content of SomeModel with list of his RelatedModel in API endpoint like:

"title": "Generations",
"description": "Short article about generations",
"related_items": [
    {
        "id": 5,
        "label": "text"
    }

]

Cause Django contains serializers to those deals, that accept entities' data and parse that to JSON according to serializer's class field, also supporting nested serializers as relations.

I would be grateful if you suggest some repositories with big Spring applications as an example, great books, or articles on that theme, cause it is hard for me to rebuild my mind and I tired from huge amount of ultra-simple article's examples.

You probably haven't linked the entities correctly.

Try reading this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM