Spring Data Rest how to deactivate collections into references



  • How do you turn off the collections of relationships (in my case Set) in the tele-referencing?

    There are @OneToMany and @ManyToOne There's a repository inherited from JpaRepository. SpringBut's app, everything's working on the Spring date. I mean, the counter-allers and the services are spying on themselves. Owner and Cat classes are lower for illustration

    @Entity
    public class Cat{
    
    @Id
    Long Id;
    
    String catName;
    
    @ManyToOne(...)
    Owner owner;
    

    Master class

    @Entity
    public class Owner{

    @Id
    Long Id;
    
    String ownerName;
    
    @OneToMany(...)
    Set<Cat> pets;
    

    It's working, the classes are set up, and the cat's net reaches. In JSON, the conclusion is:

    {"id":"1",
    "catName":"Barsik",
    "owner":"Valera"}

    and the master

    {"id":"1",
    "ownerName":"Valera",
    "pets":[{"id":"1",
    "catName":"Barsik",
    "owner":"Valera"}]}

    NO! Spring Data provides HAL+JSON data and the master ' s withdrawal looks like it.

    {"id":"1",
    "ownerName":"Valera",
    "_links" : {
    "self" : {
    "href" : "http://localhost:8080/owners/1"
    },
    "lot" : {
    "href" : "http://localhost:8080/owners/1"
    },
    "pets" : {
    "href" : "http://localhost:8080/owners/1/pets"}
    }}

    I'm very grateful to Spring for his care, and that he's built a speech for me, but I need to work with a model when the cat is invested in a single JSONe.

    QUESTION: How do you turn off the collections of addictions (in my case Set) into a tele-response?



  • You need to mark your interface inherited from JpaRepository (or something like that) @RepositoryRestResource(exported = false)


    https://stackoverflow.com/questions/23264044/spring-data-rest-disable-hypertext-application-language-hal-in-json-applica ♪




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2