View Javadoc

1   /**
2    * Copyright (c) 2009-2010, Elias Gomes. All rights reserved.
3    * 
4    * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
5    * following conditions are met:
6    * 
7    * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
8    * disclaimer.
9    * 
10   * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
11   * disclaimer in the documentation and/or other materials provided with the distribution.
12   * 
13   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
14   * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
15   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
16   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
17   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
18   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
19   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20   */
21  package net.sourceforge.mystique.domain.entity;
22  
23  import java.util.Date;
24  
25  import javax.persistence.Column;
26  import javax.persistence.Entity;
27  import javax.persistence.GeneratedValue;
28  import javax.persistence.GenerationType;
29  import javax.persistence.Id;
30  import javax.persistence.JoinColumn;
31  import javax.persistence.ManyToOne;
32  import javax.persistence.SequenceGenerator;
33  import javax.persistence.Table;
34  import javax.persistence.Temporal;
35  import javax.persistence.TemporalType;
36  
37  /**
38   * @author Elias Gomes [eliasgomes@users.sourceforge.net]
39   */
40  @Entity
41  @Table(name = "TB_CHANGE")
42  @SequenceGenerator(name = "changeIdSeq", sequenceName = "CHANGE_ID_SEQ", initialValue = 1, allocationSize = 1)
43  public class Change {
44  
45  	@Id
46  	@GeneratedValue(generator = "changeIdSeq", strategy = GenerationType.SEQUENCE)
47  	@Column(name = "ID")
48  	private Long id;
49  
50  	@Temporal(TemporalType.TIMESTAMP)
51  	@Column(name = "CREATED", nullable = false)
52  	private Date created;
53  
54  	@ManyToOne
55  	@JoinColumn(name = "RESPONSIBLE_USER_ID", nullable = false)
56  	private User responsible;
57  
58  	@ManyToOne
59  	@JoinColumn(name = "TICKET_ID", nullable = false)
60  	private Ticket ticket;
61  
62  	public Change() {
63  		setCreated(new Date());
64  	}
65  
66  	public Long getId() {
67  		return id;
68  	}
69  
70  	public void setId(Long id) {
71  		this.id = id;
72  	}
73  
74  	public Date getCreated() {
75  		return created;
76  	}
77  
78  	public void setCreated(Date created) {
79  		this.created = created;
80  	}
81  
82  	public User getResponsible() {
83  		return responsible;
84  	}
85  
86  	public void setResponsible(User responsible) {
87  		this.responsible = responsible;
88  	}
89  
90  	public Ticket getTicket() {
91  		return ticket;
92  	}
93  
94  	public void setTicket(Ticket ticket) {
95  		this.ticket = ticket;
96  	}
97  
98  	@Override
99  	public int hashCode() {
100 		final int prime = 31;
101 		int result = 1;
102 		result = prime * result + ((id == null) ? 0 : id.hashCode());
103 		return result;
104 	}
105 
106 	@Override
107 	public boolean equals(Object obj) {
108 		if (this == obj)
109 			return true;
110 		if (obj == null)
111 			return false;
112 		if (getClass() != obj.getClass())
113 			return false;
114 		Change other = (Change) obj;
115 		if (id == null) {
116 			if (other.id != null)
117 				return false;
118 		} else if (!id.equals(other.id))
119 			return false;
120 		return true;
121 	}
122 
123 }