I have MyEntity class:
@Entity
@Table("entities)
public class MyEntity {
@ID
private String name;
@Column(name="age")
private int age;
@Column(name="weight")
private int weight;
...getters and setters..
}
In @RestController there are 2 @GetMapping methods. The first:
@GetMapping
public MyEntity get(){
...
return myEntity;
}
The second:
@GetMapping("url")
public List<MyEntity> getAll(){
...
return entities;
}
It's needed to provide:
1. @GetMapping returns entity as it's described in MyEntity class.
2. @GetMapping("url") returns entities like one of its fields is with @JsonIgnore.
UPDATE:
When I return myEntity, client will get, for example:
{
"name":"Alex",
"age":30,
"weight":70
}
I want in the same time using the same ENTITY have an opportunity depending on the URL send to client:
1.
{
"name":"Alex",
"age":30,
"weight":70
}
2.
{
"name":"Alex",
"age":30
}