MongoDB Java driver 3.5 supports reference fields in POJO

In magonodb java driver 3.5 version “official support” for added POJO mapping .

But it doesn't seem to say anything about mapping a class to a specific set or storing the pojo field of a class in a separate collection, rather than 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 do this so that inserting an instance Personactually inserts something like {id={some oid}, address={oid1}}into the collection peopleand {id={oid1}, zip={some zipcode}}into addressescollection

Will this appear in a later release, or did I just skip some annotation or configuration step?

+4
source share

Source: https://habr.com/ru/post/1683268/


All Articles