Last active
August 29, 2015 14:06
-
-
Save gunnarmorling/ed8838c314d447b76a2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
public class Court { | |
@EmbeddedId | |
private CourtId id; | |
private String name; | |
@OneToMany(mappedBy = "playedOn") | |
private Set<Game> games = new HashSet<Game>(); | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
public class Game { | |
@EmbeddedId | |
private GameId id; | |
private String name; | |
@ManyToOne | |
private Court playedOn; | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> 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" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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