Pessoal, eu pedi pra gerar automaticamente a classe de entidade do banco de dados, porém ele me gerou para 1 tabela, 2 classes, e eu estou precisando pegar os valores na combinação de ambos. Como eu faço isso no jsf?
aqui estão as classes:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package br.com.mid.pac.demandas.modelo;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name = "fun_funcionario", catalog = "intranet", schema = "")
@NamedQueries({
@NamedQuery(name = "FunFuncionario.findGerentesDiretores", query = "SELECT f FROM FunFuncionario f where f.codDependencia = 8598")
/*
,
@NamedQuery(name = "FunFuncionario.findAll", query = "SELECT f FROM FunFuncionario f"),
@NamedQuery(name = "FunFuncionario.findByMatricula", query = "SELECT f FROM FunFuncionario f WHERE f.matricula = :matricula"),
@NamedQuery(name = "FunFuncionario.findByCodDependencia", query = "SELECT f FROM FunFuncionario f WHERE f.codDependencia = :codDependencia"),
@NamedQuery(name = "FunFuncionario.findByNome", query = "SELECT f FROM FunFuncionario f WHERE f.nome = :nome"),
@NamedQuery(name = "FunFuncionario.findByNomeGuerra", query = "SELECT f FROM FunFuncionario f WHERE f.nomeGuerra = :nomeGuerra"),
@NamedQuery(name = "FunFuncionario.findByDtNascimento", query = "SELECT f FROM FunFuncionario f WHERE f.dtNascimento = :dtNascimento"),
@NamedQuery(name = "FunFuncionario.findByTipoFuncionario", query = "SELECT f FROM FunFuncionario f WHERE f.tipoFuncionario = :tipoFuncionario"),
@NamedQuery(name = "FunFuncionario.findByExcluido", query = "SELECT f FROM FunFuncionario f WHERE f.excluido = :excluido"),
@NamedQuery(name = "FunFuncionario.findByTelTrabalho", query = "SELECT f FROM FunFuncionario f WHERE f.telTrabalho = :telTrabalho"),
@NamedQuery(name = "FunFuncionario.findByTelResidencia", query = "SELECT f FROM FunFuncionario f WHERE f.telResidencia = :telResidencia"),
@NamedQuery(name = "FunFuncionario.findByTelCelular", query = "SELECT f FROM FunFuncionario f WHERE f.telCelular = :telCelular"),
@NamedQuery(name = "FunFuncionario.findByTelFax", query = "SELECT f FROM FunFuncionario f WHERE f.telFax = :telFax"),
@NamedQuery(name = "FunFuncionario.findByEmailbb", query = "SELECT f FROM FunFuncionario f WHERE f.emailbb = :emailbb"),
@NamedQuery(name = "FunFuncionario.findByEmail", query = "SELECT f FROM FunFuncionario f WHERE f.email = :email"),
@NamedQuery(name = "FunFuncionario.findByEndereco", query = "SELECT f FROM FunFuncionario f WHERE f.endereco = :endereco"),
@NamedQuery(name = "FunFuncionario.findByEnderecoAlt", query = "SELECT f FROM FunFuncionario f WHERE f.enderecoAlt = :enderecoAlt")
*/
})
public class FunFuncionario implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "matricula")
private String matricula;
@Basic(optional = false)
@Column(name = "cod_dependencia")
private int codDependencia;
@Basic(optional = false)
@Column(name = "nome")
private String nome;
@Column(name = "nome_guerra")
private String nomeGuerra;
@Basic(optional = false)
@Column(name = "dt_nascimento")
@Temporal(TemporalType.DATE)
private Date dtNascimento;
@Basic(optional = false)
@Column(name = "tipo_funcionario")
private String tipoFuncionario;
@Basic(optional = false)
@Column(name = "excluido")
private String excluido;
@Column(name = "tel_trabalho")
private String telTrabalho;
@Column(name = "tel_residencia")
private String telResidencia;
@Column(name = "tel_celular")
private String telCelular;
@Column(name = "tel_fax")
private String telFax;
@Column(name = "emailbb")
private String emailbb;
@Column(name = "email")
private String email;
@Column(name = "endereco")
private String endereco;
@Column(name = "endereco_alt")
private String enderecoAlt;
@JoinColumn(name = "cod_divisao", referencedColumnName = "cod_divisao")
@ManyToOne(fetch = FetchType.LAZY)
private FunDivisao funDivisao;
@JoinColumn(name = "cod_cargo", referencedColumnName = "cod_cargo")
@ManyToOne(optional = false, fetch = FetchType.LAZY)
private FunCargo funCargo;
public FunFuncionario() {
}
public FunFuncionario(String matricula) {
this.matricula = matricula;
}
public FunFuncionario(String matricula, int codDependencia, String nome, Date dtNascimento, String tipoFuncionario, String excluido) {
this.matricula = matricula;
this.codDependencia = codDependencia;
this.nome = nome;
this.dtNascimento = dtNascimento;
this.tipoFuncionario = tipoFuncionario;
this.excluido = excluido;
}
public String getMatricula() {
return matricula;
}
public void setMatricula(String matricula) {
this.matricula = matricula;
}
public int getCodDependencia() {
return codDependencia;
}
public void setCodDependencia(int codDependencia) {
this.codDependencia = codDependencia;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getNomeGuerra() {
return nomeGuerra;
}
public void setNomeGuerra(String nomeGuerra) {
this.nomeGuerra = nomeGuerra;
}
public Date getDtNascimento() {
return dtNascimento;
}
public void setDtNascimento(Date dtNascimento) {
this.dtNascimento = dtNascimento;
}
public String getTipoFuncionario() {
return tipoFuncionario;
}
public void setTipoFuncionario(String tipoFuncionario) {
this.tipoFuncionario = tipoFuncionario;
}
public String getExcluido() {
return excluido;
}
public void setExcluido(String excluido) {
this.excluido = excluido;
}
public String getTelTrabalho() {
return telTrabalho;
}
public void setTelTrabalho(String telTrabalho) {
this.telTrabalho = telTrabalho;
}
public String getTelResidencia() {
return telResidencia;
}
public void setTelResidencia(String telResidencia) {
this.telResidencia = telResidencia;
}
public String getTelCelular() {
return telCelular;
}
public void setTelCelular(String telCelular) {
this.telCelular = telCelular;
}
public String getTelFax() {
return telFax;
}
public void setTelFax(String telFax) {
this.telFax = telFax;
}
public String getEmailbb() {
return emailbb;
}
public void setEmailbb(String emailbb) {
this.emailbb = emailbb;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getEndereco() {
return endereco;
}
public void setEndereco(String endereco) {
this.endereco = endereco;
}
public String getEnderecoAlt() {
return enderecoAlt;
}
public void setEnderecoAlt(String enderecoAlt) {
this.enderecoAlt = enderecoAlt;
}
public FunDivisao getFunDivisao() {
return funDivisao;
}
public void setFunDivisao(FunDivisao funDivisao) {
this.funDivisao = funDivisao;
}
public FunCargo getFunCargo() {
return funCargo;
}
public void setFunCargo(FunCargo funCargo) {
this.funCargo = funCargo;
}
@Override
public int hashCode() {
int hash = 0;
hash += (matricula != null ? matricula.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 FunFuncionario)) {
return false;
}
FunFuncionario other = (FunFuncionario) object;
if ((this.matricula == null && other.matricula != null) || (this.matricula != null && !this.matricula.equals(other.matricula))) {
return false;
}
return true;
}
@Override
public String toString() {
return "br.com.bb.direv.demandas.modelo.FunFuncionario[matricula=" + matricula + "]";
}
}
e esta:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package br.com.mid.pac.demandas.modelo;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "fun_cargo", catalog = "intranet", schema = "")
@NamedQueries({
/*
@NamedQuery(name = "FunCargo.findAll", query = "SELECT f FROM FunCargo f"),
@NamedQuery(name = "FunCargo.findByCodCargo", query = "SELECT f FROM FunCargo f WHERE f.codCargo = :codCargo"),
@NamedQuery(name = "FunCargo.findByNomeCargo", query = "SELECT f FROM FunCargo f WHERE f.nomeCargo = :nomeCargo")*/
})
public class FunCargo implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "cod_cargo")
private Integer codCargo;
@Basic(optional = false)
@Column(name = "nome_cargo")
private String nomeCargo;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "funCargo", fetch = FetchType.LAZY)
private List<FunFuncionario> funFuncionarioList;
public FunCargo() {
}
public FunCargo(Integer codCargo) {
this.codCargo = codCargo;
}
public FunCargo(Integer codCargo, String nomeCargo) {
this.codCargo = codCargo;
this.nomeCargo = nomeCargo;
}
public Integer getCodCargo() {
return codCargo;
}
public void setCodCargo(Integer codCargo) {
this.codCargo = codCargo;
}
public String getNomeCargo() {
return nomeCargo;
}
public void setNomeCargo(String nomeCargo) {
this.nomeCargo = nomeCargo;
}
public List<FunFuncionario> getFunFuncionarioList() {
return funFuncionarioList;
}
public void setFunFuncionarioList(List<FunFuncionario> funFuncionarioList) {
this.funFuncionarioList = funFuncionarioList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (codCargo != null ? codCargo.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 FunCargo)) {
return false;
}
FunCargo other = (FunCargo) object;
if ((this.codCargo == null && other.codCargo != null) || (this.codCargo != null && !this.codCargo.equals(other.codCargo))) {
return false;
}
return true;
}
@Override
public String toString() {
return "br.com.bb.direv.demandas.modelo.FunCargo[codCargo=" + codCargo + "]";
}
}
eu preciso pegar os nomes de acordo com o código do cargo, mão não sei como fazer inner join nesse caso