Guest User

Categorie.entity

a guest
Dec 9th, 2011
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.12 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package com.javaxia.business.entities;
  6.  
  7. import java.io.Serializable;
  8. import java.util.Collection;
  9. import javax.persistence.Basic;
  10. import javax.persistence.CascadeType;
  11. import javax.persistence.Column;
  12. import javax.persistence.Entity;
  13. import javax.persistence.GeneratedValue;
  14. import javax.persistence.GenerationType;
  15. import javax.persistence.Id;
  16. import javax.persistence.Lob;
  17. import javax.persistence.NamedQueries;
  18. import javax.persistence.NamedQuery;
  19. import javax.persistence.OneToMany;
  20. import javax.persistence.Table;
  21. import javax.validation.constraints.NotNull;
  22. import javax.validation.constraints.Size;
  23. import javax.xml.bind.annotation.XmlRootElement;
  24. import javax.xml.bind.annotation.XmlTransient;
  25.  
  26. /**
  27.  *
  28.  * @author Cristallix
  29.  */
  30. @Entity
  31. @Table(name = "categorie")
  32. @XmlRootElement
  33. @NamedQueries({
  34.     @NamedQuery(name = "Categorie.findAll", query = "SELECT c FROM Categorie c"),
  35.     @NamedQuery(name = "Categorie.findByIdCat", query = "SELECT c FROM Categorie c WHERE c.idCat = :idCat")})
  36. public class Categorie implements Serializable {
  37.     private static final long serialVersionUID = 1L;
  38.     @Id
  39.     @GeneratedValue(strategy = GenerationType.IDENTITY)
  40.     @Basic(optional = false)
  41.     @NotNull
  42.     @Column(name = "ID_CAT")
  43.     private Integer idCat;
  44.     @Basic(optional = false)
  45.     @NotNull
  46.     @Lob
  47.     @Size(min = 1, max = 65535)
  48.     @Column(name = "NOM_CAT")
  49.     private String nomCat;
  50.     @OneToMany(cascade = CascadeType.ALL, mappedBy = "idCat")
  51.     private Collection<Livre> livreCollection;
  52.  
  53.     public Categorie() {
  54.     }
  55.  
  56.     public Categorie(Integer idCat) {
  57.         this.idCat = idCat;
  58.     }
  59.  
  60.     public Categorie(Integer idCat, String nomCat) {
  61.         this.idCat = idCat;
  62.         this.nomCat = nomCat;
  63.     }
  64.  
  65.     public Integer getIdCat() {
  66.         return idCat;
  67.     }
  68.  
  69.     public void setIdCat(Integer idCat) {
  70.         this.idCat = idCat;
  71.     }
  72.  
  73.     public String getNomCat() {
  74.         return nomCat;
  75.     }
  76.  
  77.     public void setNomCat(String nomCat) {
  78.         this.nomCat = nomCat;
  79.     }
  80.  
  81.     @XmlTransient
  82.     public Collection<Livre> getLivreCollection() {
  83.         return livreCollection;
  84.     }
  85.  
  86.     public void setLivreCollection(Collection<Livre> livreCollection) {
  87.         this.livreCollection = livreCollection;
  88.     }
  89.  
  90.     @Override
  91.     public int hashCode() {
  92.         int hash = 0;
  93.         hash += (idCat != null ? idCat.hashCode() : 0);
  94.         return hash;
  95.     }
  96.  
  97.     @Override
  98.     public boolean equals(Object object) {
  99.         // TODO: Warning - this method won't work in the case the id fields are not set
  100.         if (!(object instanceof Categorie)) {
  101.             return false;
  102.         }
  103.         Categorie other = (Categorie) object;
  104.         if ((this.idCat == null && other.idCat != null) || (this.idCat != null && !this.idCat.equals(other.idCat))) {
  105.             return false;
  106.         }
  107.         return true;
  108.     }
  109.  
  110.     @Override
  111.     public String toString() {
  112.         return "com.javaxia.entities.Categorie[ idCat=" + idCat + " ]";
  113.     }
  114.    
  115. }
  116.  
  117.  
Advertisement
Add Comment
Please, Sign In to add comment