MongoDB Java driver 3.5 support for reference fields in POJOs

Viewed 432

In the mongodb java driver 3.5 release, "official support" for POJO mapping was added.

But it doesn't seem to mention anything about mapping a class to specific collection or storing a pojo field of a class in a separate collection instead of embedding it.

Given:

public class Address {
    public ObjectId id;
    public String zipcode;
}

//elsewhere
public class Person {
    public ObjectId id;
    public Address address;
}

How do you make it so that inserting a Person instance actually inserts something like {id={some oid}, address={oid1}} in people collection, and {id={oid1}, zip={some zipcode}} in addresses collection

Will that be coming in a later release or did I just miss some annotation or config step?

0 Answers
Related