I'm trying to implement a rest api using RepositoryRestResource
and RestTemplate
It all works rather well, except for loading @DBRef's
Consider this data model:
public class Order
{
@Id
String id;
@DBRef
Customer customer;
... other stuff
}
public class Customer
{
@Id
String id;
String name;
...
}
And the following repository (similar one for customer)
@RepositoryRestResource(excerptProjection = OrderSummary.class)
public interface OrderRestRepository extends MongoRepositor<Order,String>{}
The rest api returns the following JSON:
{
"id" : 4,
**other stuff**,
"_links" : {
"self" : {
"href" : "http://localhost:12345/api/orders/4"
},
"customer" : {
"href" : "http://localhost:12345/api/orders/4/customer"
}
}
}
Which if loaded correctly by the resttemplate will create a new Order instance with customer = null
Is it possible to eagerly resolve the customer on the repository end and embed the JSON?