001 /*
002 * To change this template, choose Tools | Templates
003 * and open the template in the editor.
004 */
005
006 package com.vendidata.gollum.reftests;
007
008 import java.io.Serializable;
009 import java.util.ArrayList;
010 import java.util.List;
011 import javax.persistence.Column;
012 import javax.persistence.Entity;
013 import javax.persistence.FetchType;
014 import javax.persistence.GeneratedValue;
015 import javax.persistence.GenerationType;
016 import javax.persistence.Id;
017 import javax.persistence.JoinColumn;
018 import javax.persistence.JoinTable;
019 import javax.persistence.ManyToMany;
020 import javax.persistence.Table;
021
022 /**
023 *
024 * @author christianreiter
025 */
026 @Entity
027 @Table(name = "city")
028 public class City implements Serializable {
029 private static final long serialVersionUID = 1L;
030
031 @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
032 @Column(name = "C_ID", nullable = false)
033 private Integer id;
034
035 @Column(name = "C_CITY", nullable = false)
036 private String city;
037
038 @ManyToMany(fetch=FetchType.EAGER)
039 @JoinTable(name="CITY_PERSON",joinColumns=@JoinColumn(name="C_ID"),inverseJoinColumns=@JoinColumn(name="P_ID"))
040 private List<Person> persons = new ArrayList<Person>();
041
042 public City() {
043 }
044
045 public City(Integer id) {
046 this.id = id;
047 }
048
049 public City(Integer id, String city) {
050 this.id = id;
051 this.city = city;
052 }
053
054 public Integer getId() {
055 return id;
056 }
057
058 public void setId(Integer cId) {
059 this.id = cId;
060 }
061
062 public String getCity() {
063 return city;
064 }
065
066 public void setCity(String cCity) {
067 this.city = cCity;
068 }
069
070 public List<Person> getPersons() {
071 return persons;
072 }
073
074 public void setPersons(List<Person> persons) {
075 this.persons = persons;
076 }
077
078
079
080 @Override
081 public int hashCode() {
082 int hash = 0;
083 hash += (id != null ? id.hashCode() : 0);
084 return hash;
085 }
086
087 @Override
088 public boolean equals(Object object) {
089 // TODO: Warning - this method won't work in the case the id fields are not set
090 if (!(object instanceof City)) {
091 return false;
092 }
093 City other = (City) object;
094 if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
095 return false;
096 }
097 return true;
098 }
099
100 @Override
101 public String toString() {
102 return "com.vendidata.gollum.reftests.City[cId=" + id + "]";
103 }
104
105 }
|