boa tarde pessoal, to dando uma estudada aqui no hibernate e utilizando o mesmo com netbeans 6.5…to achando show…ja persistiu tudo…mas agora eu quero buscar…vi que quando gero o VO automaticamente a partir da tabela do banco e me traz umas buscas padroes, tipo getElementoById…etc…queria saber como usar isso…to usando com Annotations…
aqui vai meu VO
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package vo;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Query;
import javax.persistence.Table;
/**
*
* @author abel
*/
@Entity
@Table(name = "cliente")
@NamedQueries({@NamedQuery(name = "VOCliente.findAll", query = "SELECT v FROM VOCliente v"), @NamedQuery(name = "VOCliente.findByIdCliente", query = "SELECT v FROM VOCliente v WHERE v.idCliente = :idCliente"), @NamedQuery(name = "VOCliente.findByNomeCLiente", query = "SELECT v FROM VOCliente v WHERE v.nomeCLiente = :nomeCLiente"), @NamedQuery(name = "VOCliente.findByEnderecoCliente", query = "SELECT v FROM VOCliente v WHERE v.enderecoCliente = :enderecoCliente"), @NamedQuery(name = "VOCliente.findByTelefoneCliente", query = "SELECT v FROM VOCliente v WHERE v.telefoneCliente = :telefoneCliente")})
public class VOCliente implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "idCliente")
private Integer idCliente;
@Column(name = "nomeCLiente")
private String nomeCLiente;
@Column(name = "enderecoCliente")
private String enderecoCliente;
@Column(name = "telefoneCliente")
private String telefoneCliente;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "cliente")
private Collection<VOVenda> vOVendaCollection;
public VOCliente() {
}
public VOCliente(Integer idCliente) {
this.idCliente = idCliente;
}
public Integer getIdCliente() {
return idCliente;
}
public void setIdCliente(Integer idCliente) {
this.idCliente = idCliente;
}
public String getNomeCLiente() {
return nomeCLiente;
}
public void setNomeCLiente(String nomeCLiente) {
this.nomeCLiente = nomeCLiente;
}
public String getEnderecoCliente() {
return enderecoCliente;
}
public void setEnderecoCliente(String enderecoCliente) {
this.enderecoCliente = enderecoCliente;
}
public String getTelefoneCliente() {
return telefoneCliente;
}
public void setTelefoneCliente(String telefoneCliente) {
this.telefoneCliente = telefoneCliente;
}
public Collection<VOVenda> getVOVendaCollection() {
return vOVendaCollection;
}
public void setVOVendaCollection(Collection<VOVenda> vOVendaCollection) {
this.vOVendaCollection = vOVendaCollection;
}
@Override
public int hashCode() {
int hash = 0;
hash += (idCliente != null ? idCliente.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof VOCliente)) {
return false;
}
VOCliente other = (VOCliente) object;
if ((this.idCliente == null && other.idCliente != null) || (this.idCliente != null && !this.idCliente.equals(other.idCliente))) {
return false;
}
return true;
}
@Override
public String toString() {
return "vo.VOCliente[idCliente=" + idCliente + "]";
}
}
agradeço desde já…