Reputation: 708
I have a scenario where i have to fine multiple queries to get the result. Since EntityView is interface and if i want to send API response with some custom attributes that is not defined in Entity, how can i do that?
@EntityView(DealListing.class)
public abstract class DealListingBuyerView {
abstract Long getId();
abstract Long getDealTypeId();
abstract DealRelatedType getDealRelatedType();
abstract String getRelatedCode();
abstract DealStatus getDealListingStatus();
abstract String getDealListingCompletionRate();
abstract DealRefDataBuyerView getDealRefData();
}
The last attribute DealRefDataBuyerView is not a field in the Entity
Upvotes: 0
Views: 271
Reputation: 16400
I don't know where the value comes from, so I can only guess. You have various mapping annotations that you can use to access values or use expressions to model what you need like e.g. @Mapping
. See the documentation for more details. Here is an example where you would join the data based on some custom join condition DealRef.deal.id = DealListing.id
:
@EntityView(DealListing.class)
public interface DealListingBuyerView {
@IdMapping
Long getId();
Long getDealTypeId();
DealRelatedType getDealRelatedType();
String getRelatedCode();
DealStatus getDealListingStatus();
String getDealListingCompletionRate();
@Mapping("DealRef[deal.id = VIEW(id)]")
DealRefDataBuyerView getDealRefData();
}
Upvotes: 1