Created
December 18, 2008 07:58
-
-
Save shimarin/37431 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 | |
@IdClass(FootballerPk.class) | |
public class Footballer { | |
//part of the id key | |
@Id public String getFirstname() { | |
return firstname; | |
} | |
public void setFirstname(String firstname) { | |
this.firstname = firstname; | |
} | |
//part of the id key | |
@Id public String getLastname() { | |
return lastname; | |
} | |
public void setLastname(String lastname) { | |
this.lastname = lastname; | |
} | |
public String getClub() { | |
return club; | |
} | |
public void setClub(String club) { | |
this.club = club; | |
} | |
//appropriate equals() and hashCode() implementation | |
} | |
@Embeddable | |
public class FootballerPk implements Serializable { | |
//same name and type as in Footballer | |
public String getFirstname() { | |
return firstname; | |
} | |
public void setFirstname(String firstname) { | |
this.firstname = firstname; | |
} | |
//same name and type as in Footballer | |
public String getLastname() { | |
return lastname; | |
} | |
public void setLastname(String lastname) { | |
this.lastname = lastname; | |
} | |
//appropriate equals() and hashCode() implementation | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment