@marenet escreveu:
Pessoal estou tendo dificuldade em uma pesquisa com uma consulta.
Tenho essas duas tabelas:public class Filial implements Serializable{
private static final long serialVersionUID = 1L; @Id @Column(name = "COD_FILIAL", columnDefinition = "char(6)") private String codigo; @Column(name = "DSFILIAL", columnDefinition = "char(30)") private String descricao; @Column(name = "DSFILIALREDUZIDA", columnDefinition = "char(12)") private String descricaoReduzida;
@Entity
@Table(name="FILIAL_LOCAL",
uniqueConstraints={@UniqueConstraint(name="UK_FILIAL_LOCAL",columnNames={"COD_FILIAL","COD_LOCAL"})})
public class Local implements Serializable{private static final long serialVersionUID = 1L; @Id @Column(name = "CHAVE_LOCAL", columnDefinition = "char(8)") private String chaveLocal; @Column(name = "COD_LOCAL", columnDefinition = "char(2)") private String codigo; @ManyToOne(optional = false) @JoinColumn(name="COD_FILIAL", nullable = false, foreignKey = @ForeignKey(name="FK_LOCAL_FILIAL")) private Filial filial; @Column(name = "NOME_LOCAL", nullable = false, columnDefinition = "char(30)") private String descricao;
Estou fazendo a seguinte consulta:
Me liste os locais de uma determinada filial.
Query query = em.createQuery("from Local l join fetch l.filial where l.filial = :filial");
query.setParameter("filial", filial);
ret = query.getResultList();porem no console me gera vaarias consultas a tabela filial, nã estou conseguindo resolver
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select local0_.CHAVE_LOCAL as CHAVE_LOCAL1_1_0_, filial1_.COD_FILIAL as COD_FILIAL1_2_1_, local0_.COD_LOCAL as COD_LOCAL2_1_0_, local0_.NOME_LOCAL as NOME_LOCAL3_1_0_, local0_.COD_FILIAL as COD_FILIAL4_1_0_, filial1_.DSFILIAL as DSFILIAL2_2_1_, filial1_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_1_ from SISSERV.FILIAL_LOCAL local0_ inner join SISSERV.Filial filial1_ on local0_.COD_FILIAL=filial1_.COD_FILIAL where local0_.COD_FILIAL=?
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Hibernate: select this_.COD_FILIAL as COD_FILIAL1_2_0_, this_.DSFILIAL as DSFILIAL2_2_0_, this_.DSFILIALREDUZIDA as DSFILIALREDUZIDA3_2_0_ from SISSERV.Filial this_ order by this_.COD_FILIAL asc
Mensagens: 2
Participantes: 2