How to get the expected result below where OrderProjection uses ItemProjection to render items using Spring Data REST
GET / orders / 1? projection = with_items
Projection:
@Projection(name = "summary", types = Item.class) public interface ItemProjection { String getName(); } @Projection(name = "with_item", types = Order.class) public interface OrderProjection { LocalDateTime getOrderedDate(); Status getStatus(); Set<ItemProjection> getItems();
Currently obtained as a conclusion:
{ "status" : "PAYMENT_EXPECTED", "orderedDate" : "2014-11-09T11:33:02.823", "items" : [ { "name" : "Java Chip", "quantity" : 1, "milk" : "SEMI", "size" : "LARGE", "price" : { "currency" : "EUR", "value" : 4.20 } } ], "_links" : { "self" : { "href" : "http://localhost:8080/orders/1{?projection}", "templated" : true }, "restbucks:items" : { "href" : "http://localhost:8080/orders/1/items" }, "curies" : [ { "href" : "http://localhost:8080/alps/{rel}", "name" : "restbucks", "templated" : true } ] } }
Expected Result:
{ "status" : "PAYMENT_EXPECTED", "orderedDate" : "2014-11-09T11:33:02.823", "items" : [ { "name" : "Java Chip" } ], "_links" : { "self" : { "href" : "http://localhost:8080/orders/1{?projection}", "templated" : true }, "restbucks:items" : { "href" : "http://localhost:8080/orders/1/items" }, "curies" : [ { "href" : "http://localhost:8080/alps/{rel}", "name" : "restbucks", "templated" : true } ] } }
source share