playframework - How can I use a compound key with the Play framework? -
playframework - How can I use a compound key with the Play framework? -
i have tried follow instructions here
http://docs.oracle.com/cd/b31017_01/web.1013/b28221/cmp30cfg001.htm
along using generic model. end primary key class follows
import javax.persistence.embeddable; import java.io.serializable; @embeddable public class dailypk implements serializable { private int match_id; private int user_id; public int getuser_id() { homecoming user_id; } public void setuser_id(int user_id) { this.user_id = user_id; } public int getmatch_id() { homecoming match_id; } public void setmatch_id(int match_id) { this.match_id = match_id; } public int hashcode() { homecoming match_id * 1000000 + user_id; } public boolean equals(object obj) { if (obj == this) homecoming true; if (!(obj instanceof dailypk)) homecoming false; if (obj == null) homecoming false; dailypk pk = (dailypk) obj; homecoming pk.match_id == match_id && pk.user_id == user_id; } }
my model class follows not compile
public class daily extends genericmodel { @id dailypk primarykey; public int round; public int score; public daily(int round, int score) { this.round = round; this.score = score; } @embeddedid public dailypk getprimarykey() { homecoming primarykey; } public void setprimarykey(dailypk pk) { primarykey = pk; } }
what modifications need make?
when extending genericmodel need override _key method
@override public object _key() { homecoming getprimarykey(); }
playframework
Comments
Post a Comment