×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Alexandros Kyriazis
Added: Jan 25, 2022 6:34 PM
Views: 395
Tags: no tags
  1. package semesterprojectv5;
  2.  
  3. import java.io.Serializable;
  4. import java.util.Collection;
  5. import javax.persistence.Basic;
  6. import javax.persistence.CascadeType;
  7. import javax.persistence.Column;
  8. import javax.persistence.Entity;
  9. import javax.persistence.GeneratedValue;
  10. import javax.persistence.GenerationType;
  11. import javax.persistence.Id;
  12. import javax.persistence.NamedQueries;
  13. import javax.persistence.NamedQuery;
  14. import javax.persistence.OneToMany;
  15. import javax.persistence.Table;
  16.  
  17. /**
  18.  *
  19.  * @author alexa
  20.  */
  21. @Table(name = "COUNTRY")
  22. @NamedQueries({
  23.     @NamedQuery(name = "Country.findAll", query = "SELECT c FROM Country c"),
  24.     @NamedQuery(name = "Country.findByCountry", query = "SELECT c FROM Country c WHERE c.country = :country"),
  25.     @NamedQuery(name = "Country.findByName", query = "SELECT c FROM Country c WHERE c.name = :name"),
  26.     @NamedQuery(name = "Country.findByLat", query = "SELECT c FROM Country c WHERE c.lat = :lat"),
  27.     @NamedQuery(name = "Country.findByLong1", query = "SELECT c FROM Country c WHERE c.long1 = :long1")})
  28. public class Country implements Serializable {
  29.  
  30.     private static final long serialVersionUID = 1L;
  31.     @Id
  32.     @GeneratedValue(strategy = GenerationType.IDENTITY)
  33.     @Basic(optional = false)
  34.     @Column(name = "COUNTRY")
  35.     private Integer country;
  36.     @Basic(optional = false)
  37.     @Column(name = "NAME")
  38.     private String name;
  39.     // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
  40.     @Column(name = "LAT")
  41.     private Double lat;
  42.     @Column(name = "LONG")
  43.     private Double long1;
  44.     @OneToMany(cascade = CascadeType.ALL, mappedBy = "country")
  45.     private Collection<Coviddata> coviddataCollection;
  46.  
  47.     public Country() {
  48.     }
  49.  
  50.     public Country(Integer country) {
  51.         this.country = country;
  52.     }
  53.  
  54.     public Country(Integer country, String name) {
  55.         this.country = country;
  56.         this.name = name;
  57.     }
  58.  
  59.     public Integer getCountry() {
  60.         return country;
  61.     }
  62.  
  63.     public void setCountry(Integer country) {
  64.         this.country = country;
  65.     }
  66.  
  67.     public String getName() {
  68.         return name;
  69.     }
  70.  
  71.     public void setName(String name) {
  72.         this.name = name;
  73.     }
  74.  
  75.     public Double getLat() {
  76.         return lat;
  77.     }
  78.  
  79.     public void setLat(Double lat) {
  80.         this.lat = lat;
  81.     }
  82.  
  83.     public Double getLong1() {
  84.         return long1;
  85.     }
  86.  
  87.     public void setLong1(Double long1) {
  88.         this.long1 = long1;
  89.     }
  90.  
  91.     public Collection<Coviddata> getCoviddataCollection() {
  92.         return coviddataCollection;
  93.     }
  94.  
  95.     public void setCoviddataCollection(Collection<Coviddata> coviddataCollection) {
  96.         this.coviddataCollection = coviddataCollection;
  97.     }
  98.  
  99.     @Override
  100.     public int hashCode() {
  101.         int hash = 0;
  102.         hash += (country != null ? country.hashCode() : 0);
  103.         return hash;
  104.     }
  105.  
  106.     @Override
  107.     public boolean equals(Object object) {
  108.         // TODO: Warning - this method won't work in the case the id fields are not set
  109.         if (!(object instanceof Country)) {
  110.             return false;
  111.         }
  112.         Country other = (Country) object;
  113.         if ((this.country == null && other.country != null) || (this.country != null && !this.country.equals(other.country))) {
  114.             return false;
  115.         }
  116.         return true;
  117.     }
  118.  
  119.     @Override
  120.     public String toString() {
  121.         return "semesterprojectv5.Country[ country=" + country + " ]";
  122.     }
  123.    
  124. }
  125.