Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select * from mydb.goal g
- JOIN mydb.matches m
- ON g.goal_match = m.matchid
- JOIN mydb.competitions c
- ON m.competition = c.competitionid
- WHERE c.competitionid = 219;
- @Entity
- public class Goal {
- @Id
- private long idgoal;
- @ManyToOne(optional = false, fetch = FetchType.LAZY)
- @JoinColumn(name = "goalMatch")
- private Match goalMatch;
- public long getIdgoal() {
- return idgoal;
- }
- public void setIdgoal(long idgoal) {
- this.idgoal = idgoal;
- }
- public Match getGoalMatch() {
- return goalMatch;
- }
- public void setGoalMatch(Match goalMatch) {
- this.goalMatch = goalMatch;
- }
- }
- @Entity(name = "matches")
- public class Match {
- @Id
- @GeneratedValue
- private long idmatch;
- @ManyToOne(optional = false, fetch = FetchType.LAZY)
- @JoinColumn(name = "competition")
- private Competition competition;
- public long getIdmatch() {
- return idmatch;
- }
- public void setIdmatch(long idmatch) {
- this.idmatch = idmatch;
- }
- public Competition getCompetition() {
- return competition;
- }
- public void setCompetition(Competition competition) {
- this.competition = competition;
- }
- }
- @Entity(name = "competitions")
- public class Competition {
- @Id
- private Long idcompetitions;
- public Long getIdcompetitions() {
- return idcompetitions;
- }
- public void setIdcompetitions(Long idcompetitions) {
- this.idcompetitions = idcompetitions;
- }
- }
Add Comment
Please, Sign In to add comment