When having the following entities:
@Entity
public class Court {
@EmbeddedId
private CourtId id;
private String name;
@OneToMany(mappedBy = "playedOn")
private Set<Game> games = new HashSet<Game>();
...
}
@Entity
public class Game {
@EmbeddedId
private GameId id;
private String name;
@ManyToOne
private Court playedOn;
...
}
Then we create the following persistent format atm. in MongoDB (need to check CouchDB as well):
> db.Game.find() { "_id" : { "category" : "primary", "sequenceNo" : "456" }
, "name" : "Bruce - Dwain", "playedOn_id" : { "countryCode" : "DE", "sequenceNo" : "123" }
} > db.Court.find() { "_id" : { "countryCode" : "DE", "sequenceNo" : "123" }
, "games" : [ { "id.sequenceNo" : "456", "id.category" : "primary" }
], "name" : "Center Court" }
> db.Game.find() { "_id" : { "category" : "primary", "sequenceNo" : "456" }
, "name" : "Bruce - Dwain", "playedOn" : { "countryCode" : "DE", "sequenceNo" : "123" }
} > db.Court.find() { "_id" : { "countryCode" : "DE", "sequenceNo" : "123" }
, "games" : [ { "sequenceNo" : "456", "category" : "primary" }
], "name" : "Center Court" }
|