Now using JPA with a container managed entity manager.
[utils] / mythtv / monitor / src / main / java / org / wamblee / mythtv / RecordingPk.java
1 /*
2  * Copyright 2006 the original author or authors.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */ 
16
17 package org.wamblee.mythtv;
18
19 import java.io.Serializable;
20 import java.util.Date;
21
22 import javax.persistence.Column;
23 import javax.persistence.Embeddable;
24 import javax.persistence.Id;
25 import javax.persistence.JoinColumn;
26 import javax.persistence.ManyToOne;
27 import javax.persistence.Temporal;
28 import javax.persistence.TemporalType;
29
30 /**
31  * 
32  */
33 @Embeddable
34 public class RecordingPk implements Serializable {
35     public Channel _channel;
36     public Date _starttime;
37     
38     public RecordingPk() { 
39         // Empty
40     }
41     
42     /**
43      * @return the channel
44      */
45     @ManyToOne
46     @JoinColumn(name="chanid")
47     public Channel getChannel() {
48         return _channel;
49     }
50     
51     /**
52      * @param aChannel the channel to set
53      */
54     public void setChannel(Channel aChannel) {
55         _channel = aChannel;
56     }
57     
58     /**
59      * @return the starttime
60      */
61     @Column(name="starttime")
62     @Temporal(TemporalType.TIMESTAMP)
63     public Date getStartTime() {
64         return _starttime;
65     }
66
67     /**
68      * @param aStarttime the starttime to set
69      */
70     public void setStartTime(Date aStarttime) {
71         _starttime = aStarttime;
72     }
73     
74     /* (non-Javadoc)
75      * @see java.lang.Object#equals(java.lang.Object)
76      */
77     @Override
78     public boolean equals(Object aObj) {
79         if ( aObj == null ) { 
80             return false; 
81         }
82         if ( !(aObj instanceof RecordingPk)) { 
83             return false; 
84         }
85         RecordingPk pk = (RecordingPk) aObj;
86         return _channel.equals(pk._channel) && _starttime.equals(pk._starttime);   
87     }
88     
89     /* (non-Javadoc)
90      * @see java.lang.Object#hashCode()
91      */
92     @Override
93     public int hashCode() {
94         return _channel.hashCode() + _starttime.hashCode(); 
95     }
96 }