简体   繁体   中英

One row repeating multiple times in spring boot Jpa .findall() response restfull api

I have an issue when I fetch data from my database with jpaReposeitory from category table which has a foriegn key userId in it. relationship of oneToMany, data is coming almost fine but it repeats itself multiple times. here are some images: categoryServiceImpl

Category Entity

json response

error

It may be due to bidirectional relationship.Try using @JsonBackReference in category class

@ManyToOne(fetch = FetchType.LAZY,optional= false)
@JsonBackReference
private User users;

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