View Javadoc

1   /**
2    * Copyright 2008 WebPhotos
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  /*
17   * To change this template, choose Tools | Templates
18   * and open the template in the editor.
19   */
20  package net.sf.webphotos.model;
21  
22  import java.io.Serializable;
23  import javax.persistence.Column;
24  import javax.persistence.Entity;
25  import javax.persistence.GeneratedValue;
26  import javax.persistence.GenerationType;
27  import javax.persistence.Id;
28  import javax.persistence.NamedQueries;
29  import javax.persistence.NamedQuery;
30  import javax.persistence.Table;
31  import net.sf.webphotos.entity.HasID;
32  import net.sf.webphotos.entity.IsCredits;
33  
34  /**
35   *
36   * @author Guilherme L A Silva
37   */
38  @Entity
39  @Table(name = "CREDITOS")
40  @NamedQueries({
41      @NamedQuery(name = "CreditsVO.findByCreditoID", query = "SELECT c FROM CreditsVO c WHERE c.creditoid = :creditoid"),
42      @NamedQuery(name = "CreditsVO.findByNome", query = "SELECT c FROM CreditsVO c WHERE c.nome = :nome")})
43  public class CreditsVO implements Serializable, HasID<Integer>, IsCredits {
44  
45      private static final long serialVersionUID = 1L;
46      
47      @Id
48      @Column(name = "CREDITOID", nullable = false)
49      @GeneratedValue(strategy = GenerationType.IDENTITY)
50      private Integer creditoid;
51      
52      @Column(name = "NOME", nullable = false)
53      private String nome;
54  
55      /**
56       *
57       */
58      public CreditsVO() {
59          nome = "";
60      }
61  
62      /**
63       *
64       * @param nome
65       */
66      public CreditsVO(String nome) {
67          this.nome = nome;
68      }
69  
70      /**
71       *
72       * @param creditoid
73       */
74      public CreditsVO(Integer creditoid) {
75          this();
76          this.creditoid = creditoid;
77      }
78  
79      /**
80       *
81       * @param creditoid
82       * @param nome
83       */
84      public CreditsVO(Integer creditoid, String nome) {
85          this();
86          this.creditoid = creditoid;
87          this.nome = nome;
88      }
89  
90      /**
91       *
92       * @return
93       */
94      public Integer getCreditoid() {
95          return creditoid;
96      }
97  
98      /**
99       *
100      * @return
101      */
102     @Override
103     public String getNome() {
104         return nome;
105     }
106 
107     /**
108      *
109      * @param nome
110      */
111     public void setNome(String nome) {
112         this.nome = nome;
113     }
114 
115     @Override
116     public int hashCode() {
117         int hash = 0;
118         hash += (creditoid != null ? creditoid.hashCode() : 0);
119         return hash;
120     }
121 
122     @Override
123     public boolean equals(Object object) {
124         // TODO: Warning - this method won't work in the case the id fields are not set
125         if (!(object instanceof CreditsVO)) {
126             return false;
127         }
128         CreditsVO other = (CreditsVO) object;
129         if ((this.creditoid == null && other.creditoid != null) || (this.creditoid != null && !this.creditoid.equals(other.creditoid))) {
130             return false;
131         }
132         return true;
133     }
134 
135     @Override
136     public String toString() {
137         return this.getClass().getCanonicalName() + "[creditoid=" + creditoid + "]";
138     }
139 
140     /**
141      *
142      * @return
143      */
144     @Override
145     public Integer getId() {
146         return creditoid;
147     }
148 }