01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype;
20:
21: import javax.persistence.*;
22:
23: @Embeddable
24: public class EmbeddedIdClass {
25:
26: @Column(name="EPK1")
27: private long pk1;
28:
29: @Column(name="EPK2")
30: private long pk2;
31:
32: @Column(name="EPK3")
33: @GeneratedValue
34: private long pk3;
35:
36: public long getPk1() {
37: return pk1;
38: }
39:
40: public void setPk1(long pk1) {
41: this .pk1 = pk1;
42: }
43:
44: public long getPk2() {
45: return pk2;
46: }
47:
48: public void setPk2(long pk2) {
49: this .pk2 = pk2;
50: }
51:
52: public long getPk3() {
53: return pk3;
54: }
55:
56: public void setPk3(long pk3) {
57: this .pk3 = pk3;
58: }
59:
60: public String toString() {
61: return pk1 + ":" + pk2 + ":" + pk3;
62: }
63:
64: public int hashCode() {
65: return (int) ((pk1 ^ pk2 ^ pk3) % Integer.MAX_VALUE);
66: }
67:
68: public boolean equals(Object other) {
69: if (other == this )
70: return true;
71: if (!(other instanceof EmbeddedIdClass))
72: return false;
73:
74: EmbeddedIdClass id = (EmbeddedIdClass) other;
75: return id.pk1 == pk1 && id.pk2 == pk2 && id.pk3 == pk3;
76: }
77: }
|