You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some fields which should be displayed in response, but not stored in db.
I'm trying to add property to response, but I can't.
Using additional getters, it doesn't work.
Using @transient fields with @PolstLoad calculate() method, it doesn't work too?
IMO Response should be controlled by @JsonIgnore/@JsonInclude instead of @transient
Is it purposeful behaviour?
Can I do this on Entity level without overrides/create controller?
The text was updated successfully, but these errors were encountered:
@Entity
public class Person {
@Id @GeneratedValue Long id;
String name;
@Transient String greeting;
public Person() {
}
public Person(Long id, String name) {
this.id = id;
this.name = name;
this.greeting = "Hello " + name;
}
@PostLoad
public void postLoad() {
this.greeting = "Hello " + name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGreeting() {
return greeting;
}
public void setGreeting(String greeting) {
this.greeting = greeting;
}
}
Please note that there is also an association for certain operations (such as PATCH) that require a property mapping between its persistent state and its REST representation.
I have some fields which should be displayed in response, but not stored in db.
I'm trying to add property to response, but I can't.
Using additional getters, it doesn't work.
Using @transient fields with @PolstLoad calculate() method, it doesn't work too?
IMO Response should be controlled by @JsonIgnore/@JsonInclude instead of @transient
Is it purposeful behaviour?
Can I do this on Entity level without overrides/create controller?
The text was updated successfully, but these errors were encountered: