Home How to include join column in json result with JPA+Hibernate
Reply: 0

How to include join column in json result with JPA+Hibernate

user699
1#
user699 Published in April 25, 2018, 6:09 pm

I have a Province class like below:

public class Province {

    @Id
    Long id;

    @Column(nullable = false)
    String name;

    @JsonManagedReference
    @OneToMany(mappedBy = "province")
    List<City> cities;

}

and a City class like below:

public class City{
    @Column(nullable = false)
    String name;

    @JsonBackReference
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "province_id")
    Province province;

}

now I want to have pronivce_id (as an int value not object) in JSON result of City in REST result.

How can I do this?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.298432 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO