/*******************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2013,2014 by Peter Pilgrim, Addiscombe, Surrey, XeNoNiQUe UK
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU GPL v3.0
* which accompanies this distribution, and is available at:
* http://www.gnu.org/licenses/gpl-3.0.txt
*
* Developers:
* Peter Pilgrim -- design, development and implementation
* -- Blog: http://www.xenonique.co.uk/blog/
* -- Twitter: @peter_pilgrim
*
* Contributors:
*
*******************************************************************************/
package je7hb.basic4.jpa.onetomany;
import javax.persistence.*;
import java.util.Collection;
import java.util.List;
/**
* The type Project
*
* @author Peter Pilgrim (peter)
*/
@Entity
public class Project implements java.io.Serializable {
@Id
@Column(name="PROJ_ID")
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private String name;
@OneToMany(cascade = CascadeType.ALL )
private Collection<Task> tasks;
public Project() {
this(null,null);
}
public Project(String name, List<Task> tasks) {
this.name = name;
this.tasks = tasks;
}
public int getId() { return id; }
public void setId(int id) { this.id = id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public Collection<Task> getTasks() { return tasks; }
public void setTasks(Collection<Task> tasks) {
this.tasks = tasks; }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Project)) return false;
Project project = (Project) o;
if (id != project.id) return false;
if (name != null ? !name.equals(project.name) : project.name != null) return false;
if (tasks != null ? !tasks.equals(project.tasks) : project.tasks != null) return false;
return true;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (tasks != null ? tasks.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "Project{" +
"id=" + id +
", name='" + name + '\'' +
", tasks=" + tasks +
'}';
}
}