@Entity | |
public class Court { | |
@EmbeddedId | |
private CourtId id; | |
private String name; | |
@OneToMany(mappedBy = "playedOn") | |
private Set<Game> games = new HashSet<Game>(); | |
... | |
} |
> 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" | |
} |
create table Court ( | |
countryCode varchar(255) not null, | |
sequenceNo varchar(255) not null, | |
name varchar(255), | |
primary key (countryCode, sequenceNo) | |
) ENGINE=InnoDB | |
create table Game ( | |
category varchar(255) not null, | |
sequenceNo varchar(255) not null, | |
name varchar(255), | |
playedOn_countryCode varchar(255), | |
playedOn_sequenceNo varchar(255), | |
primary key (category, sequenceNo) | |
) ENGINE=InnoDB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment