1 package com.trendmicro.grid.acl.ds.jpa.entities;
2
3 import javax.persistence.*;
4 import java.io.Serializable;
5
6
7
8
9
10
11
12
13
14
15
16
17 @NamedQueries({
18 @NamedQuery(name = "JobSources.SelectAssignedSourceIds", query = "" +
19 "SELECT j.id.source.sourceInformation.publicGUID FROM JOB_SOURCES j " +
20 "WHERE j.id.job.primaryKey = :primaryKey")
21 })
22 @Cacheable
23 @Entity(name = "JOB_SOURCES")
24 public class JpaJobSources implements Serializable {
25
26 private static final long serialVersionUID = -8070197419059833224L;
27
28 @EmbeddedId
29 private ID id;
30
31 public JpaJobSources() {
32 id = new ID();
33 }
34
35 public JpaJobSources(JpaJob job, JpaSource source) {
36 this();
37 id.job = job;
38 id.source = source;
39 }
40
41 public JpaJob getJob() {
42 return id.job;
43 }
44
45 public JpaSource getSource() {
46 return id.source;
47 }
48
49
50
51
52 @Embeddable
53 public static class ID implements Serializable {
54
55 private static final long serialVersionUID = -3287019005987413924L;
56
57 @ManyToOne(optional = false)
58 @JoinColumn(name = "JOB_ID")
59 private JpaJob job;
60
61 @ManyToOne(optional = false)
62 @JoinColumn(name = "SOURCE_ID")
63 private JpaSource source;
64
65 @Override
66 public boolean equals(Object o) {
67 if (this == o) return true;
68 if (!(o instanceof ID)) return false;
69 ID that = (ID) o;
70
71 if (job != null ? !job.equals(that.job) : that.job != null) return false;
72 if (source != null ? !source.equals(that.source) : that.source != null) return false;
73 return true;
74 }
75
76 @Override
77 public int hashCode() {
78 int result = job != null ? job.hashCode() : 0;
79 result = 31 * result + (source != null ? source.hashCode() : 0);
80 return result;
81 }
82
83 @Override
84 public String toString() {
85 return "ID{" +
86 "job=" + job +
87 ", source=" + source +
88 '}';
89 }
90 }
91
92 @Override
93 public String toString() {
94 return "JpaJobSources{" +
95 "id=" + id +
96 '}';
97 }
98 }