Skip to content

Instantly share code, notes, and snippets.

@FroMage
Created January 15, 2020 09:20
Show Gist options
  • Save FroMage/fd9737ad20dfd9c3fca00d4e59067fba to your computer and use it in GitHub Desktop.
Save FroMage/fd9737ad20dfd9c3fca00d4e59067fba to your computer and use it in GitHub Desktop.
@Entity
public class Person {
@Id
@GeneratedValue
private long id;
private String name;
private boolean married;
private Address address;
@ManyToOne
private Company company;
// constructors and getters
}
The resulting JSON response will be like this:
{
“_links": {
“self": {
“href": “http://localhost:8080/persons/1"
},
“person": {
“href": “http://localhost:8080/persons/1"
},
“company": {
“href": “http://localhost:8080/companies/1"
}
},
“name”: “Jonas”,
“married”: “true”,
“address”: {
“country”: “Lithuania”,
“city”: “Vilnius"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment