Colegas,
Como determino os atributos para esses métodos?
Sempre tenho que especificar todos os atributos da minha classe?
Alguém pode me dar uma explicação ou dar o link de um material legal?
Por exemplo, criei no Eclipse para a classe abaixo e por default ele seleciona todos os atributos. Isso é uma boa prática?
Muito obrigado,
Marques
@Entity
@Table(name = "produto", catalog = "loja_virtual")
public class Produto implements java.io.Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String foto;
public Produto() {
}
public Produto(String foto) {
this.foto = foto;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name = "foto", nullable = false)
@NotNull
public String getFoto() {
return this.foto;
}
public void setFoto(String foto) {
this.foto = foto;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((foto == null) ? 0 : foto.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Produto other = (Produto) obj;
if (foto == null) {
if (other.foto != null)
return false;
} else if (!foto.equals(other.foto))
return false;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}