Pessoal, estou com as 2 classes geradas. Porem n sei como fica o DAO.
Sempre dando erro.
package hbm;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Embeddable;
@Embeddable
public class AcessoPermissoesPK implements Serializable {
@Column(name = "CODPESSOA", nullable = false)
private int codpessoa;
@Column(name = "CODEMPRESA", nullable = false)
private int codempresa;
@Column(name = "FUNCAO", nullable = false)
private int funcao;
public AcessoPermissoesPK() {
}
public AcessoPermissoesPK(int funcao, int codempresa, int codpessoa) {
this.funcao = funcao;
this.codempresa = codempresa;
this.codpessoa = codpessoa;
}
public int getCodpessoa() {
return this.codpessoa;
}
public void setCodpessoa(int codpessoa) {
this.codpessoa = codpessoa;
}
public int getCodempresa() {
return this.codempresa;
}
public void setCodempresa(int codempresa) {
this.codempresa = codempresa;
}
public int getFuncao() {
return this.funcao;
}
public void setFuncao(int funcao) {
this.funcao = funcao;
}
public int hashCode() {
int hash = 0;
hash += (int)funcao;
hash += (int)codempresa;
hash += (int)codpessoa;
return hash;
}
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof AcessoPermissoesPK)) {
return false;
}
AcessoPermissoesPK other = (AcessoPermissoesPK)object;
if (this.funcao != other.funcao) return false;
if (this.codempresa != other.codempresa) return false;
if (this.codpessoa != other.codpessoa) return false;
return true;
}
@Override
public String toString() {
return "hbm.AcessoPermissoesPK[funcao=" + funcao + ", codempresa=" + codempresa + ", codpessoa=" + codpessoa + "]";
}
}
package hbm;
import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
@Entity
@Table(name = "acesso_permissoes")
@NamedQueries( {
@NamedQuery(name = "AcessoPermissoes.findByCodpessoa", query = "SELECT a FROM AcessoPermissoes a WHERE a.acessoPermissoesPK.codpessoa = :codpessoa"),
@NamedQuery(name = "AcessoPermissoes.findByCodempresa", query = "SELECT a FROM AcessoPermissoes a WHERE a.acessoPermissoesPK.codempresa = :codempresa"),
@NamedQuery(name = "AcessoPermissoes.findByFuncao", query = "SELECT a FROM AcessoPermissoes a WHERE a.acessoPermissoesPK.funcao = :funcao")
})
public class AcessoPermissoes implements Serializable {
@EmbeddedId
protected AcessoPermissoesPK acessoPermissoesPK;
@JoinColumn(name = "CODPESSOA", referencedColumnName = "COD_PESSOA", insertable = false, updatable = false)
@ManyToOne
private Pessoa pessoa;
public AcessoPermissoes() {
}
public AcessoPermissoes(AcessoPermissoesPK acessoPermissoesPK) {
this.acessoPermissoesPK = acessoPermissoesPK;
}
public AcessoPermissoes(int funcao, int codempresa, int codpessoa) {
this.acessoPermissoesPK = new AcessoPermissoesPK(funcao, codempresa, codpessoa);
}
public AcessoPermissoesPK getAcessoPermissoesPK() {
return this.acessoPermissoesPK;
}
public void setAcessoPermissoesPK(AcessoPermissoesPK acessoPermissoesPK) {
this.acessoPermissoesPK = acessoPermissoesPK;
}
public Pessoa getPessoa() {
return this.pessoa;
}
public void setPessoa(Pessoa pessoa) {
this.pessoa = pessoa;
}
public int hashCode() {
int hash = 0;
hash += (this.acessoPermissoesPK != null ? this.acessoPermissoesPK.hashCode() : 0);
return hash;
}
public boolean equals(Object object) {
if (!(object instanceof AcessoPermissoes)) {
return false;
}
AcessoPermissoes other = (AcessoPermissoes)object;
if (this.acessoPermissoesPK != other.acessoPermissoesPK && (this.acessoPermissoesPK == null || !this.acessoPermissoesPK.equals(other.acessoPermissoesPK))) return false;
return true;
}
public String toString() {
return "hbm.AcessoPermissoes[acessoPermissoesPK=" + acessoPermissoesPK + "]";
}
}