0

In spring boot starter data rest 2.7.4 the following problem arises when defining a relationship in this way.

        @ManyToOne
    @JoinColumn(name = "country_id", referencedColumnName = "id")
    private Country country;

       
    public Country getCountry() {
        return country;
    }

    public void setCountry(Country country) {
        this.country = country;
    }

All time return a relation user:null

The only solution I have found is to modify it as follows.

        @ManyToOne
    @JoinColumn(name = "country_id", referencedColumnName = "id")
    private Country countries;

      
    public Country getCountry() {
        return countries;
    }

    public void setCountry(Country country) {
        this.countries = country;
    }

by changing the name of the property and leaving the setter and getter different if the relationship resolves.

I will appreciate any help or information regarding this.

  • 1
    Sorry cannot reproduce/sounds really weird! Please do a [mre]. (I can name variable&"accessors" anyhow. As long (db) data is consistent, i get a non-null relationship) – xerx593 Nov 24 '22 at 22:38
  • Sorry I updated my question check the followed link :https://stackoverflow.com/questions/74603524/spring-data-rest-relationship-return-null-and-not-save-and-not-update – Daniel Angel Nov 28 '22 at 16:19

0 Answers0