1 package ejava.examples.orm.rel.annotated;
2
3 import javax.persistence.*;
4
5 import org.apache.commons.logging.Log;
6 import org.apache.commons.logging.LogFactory;
7
8 import ejava.examples.orm.rel.MediaCopyPK;
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 @Entity @Table(name="ORMREL_MEDIACOPY")
43 @IdClass(MediaCopyPK.class)
44 public class MediaCopy {
45 private static final Log log = LogFactory.getLog(MediaCopy.class);
46 @Id
47 private int copyNo;
48 @Id
49 private long mediaId;
50 @ManyToOne
51 @JoinColumn(name="MEDIACOPY_MID",
52 insertable=false, updatable=false)
53 private Media media;
54
55 protected MediaCopy() { log.debug(super.toString() + ": ctor()"); }
56 public MediaCopy(Media media, int copyNo) {
57 log.debug(super.toString() + ": ctor() mediaId="
58 + media.getId() + ", copyNo=" + copyNo);
59 setMedia(media);
60 setMediaId(media.getId());
61 setCopyNo(copyNo);
62 }
63
64 public int getCopyNo() { return copyNo; }
65 private void setCopyNo(int copyNo) { this.copyNo = copyNo; }
66
67 public long getMediaId() { return mediaId; }
68 private void setMediaId(long mediaId) { this.mediaId = mediaId; }
69
70 public Media getMedia() { return media; }
71 private void setMedia(Media media) { this.media = media; }
72
73 public String toString() {
74 return super.toString() +
75 ", mediaId=" + mediaId +
76 ", copyNo=" + copyNo +
77 ", media=" + media;
78 }
79 }