• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with performance on OneToOne mapping

 
David de Lucca
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I have a bidrectional mapping OneToOne:

TalonTO


AssociateTO


The problem is that im doing a select clause on ASSOCIATE table and its very slow because hibernate generates 2 queries for it:


12:21:29,718 INFO [STDOUT] Hibernate:
select
associacao0_.ID_ASSOCIACAO as ID1_0_1_,
associacao0_.ID_USUARIO_CADASTRO as ID14_0_1_,
associacao0_.ID_USUARIO_OPERADOR as ID15_0_1_,
associacao0_.ID_USUARIO_SUPERVISOR as ID13_0_1_,
associacao0_.COD_BARRAS_SUPERVISOR as COD2_0_1_,
associacao0_.COD_BARRAS_TALAO as COD3_0_1_,
associacao0_.COD_BARRAS_OPERADOR as COD4_0_1_,
associacao0_.COD_BARRAS_CADASTRO as COD5_0_1_,
associacao0_.ID_TALAO as ID16_0_1_,
associacao0_.DT_CADASTRO_SISTEMA as DT6_0_1_,
associacao0_.DT_CADASTRO_SUPERVISOR as DT7_0_1_,
associacao0_.DT_CADASTRO_OPERADOR as DT8_0_1_,
associacao0_.DT_DEVOLUCAO_OPERADOR as DT9_0_1_,
associacao0_.DT_DEVOLUCAO_SUPERVISOR as DT10_0_1_,
associacao0_.DT_PERDIDO as DT11_0_1_,
associacao0_.DT_SUSPENSO as DT12_0_1_,
talaoto1_.ID_TALAO as ID1_6_0_,
talaoto1_.COD_BARRA as COD2_6_0_,
talaoto1_.NUM_INICIO as NUM3_6_0_,
talaoto1_.NUM_FIM as NUM4_6_0_,
talaoto1_.ID_STATUS_TALAO as ID5_6_0_,
talaoto1_.FL_COMPLETO as FL6_6_0_,
talaoto1_.FL_DELETADO as FL7_6_0_,
talaoto1_.QUANTIDADE_RECEBIDA as QUANTIDADE8_6_0_
from
ASSOCIACAO associacao0_
left outer join
TALAO talaoto1_
on associacao0_.ID_TALAO=talaoto1_.ID_TALAO
where
associacao0_.ID_TALAO=?
12:21:29,843 INFO [STDOUT] Hibernate:
select
talaoto0_.ID_TALAO as ID1_6_1_,
talaoto0_.COD_BARRA as COD2_6_1_,
talaoto0_.NUM_INICIO as NUM3_6_1_,
talaoto0_.NUM_FIM as NUM4_6_1_,
talaoto0_.ID_STATUS_TALAO as ID5_6_1_,
talaoto0_.FL_COMPLETO as FL6_6_1_,
talaoto0_.FL_DELETADO as FL7_6_1_,
talaoto0_.QUANTIDADE_RECEBIDA as QUANTIDADE8_6_1_,
associacao1_.ID_ASSOCIACAO as ID1_0_0_,
associacao1_.ID_USUARIO_CADASTRO as ID14_0_0_,
associacao1_.ID_USUARIO_OPERADOR as ID15_0_0_,
associacao1_.ID_USUARIO_SUPERVISOR as ID13_0_0_,
associacao1_.COD_BARRAS_SUPERVISOR as COD2_0_0_,
associacao1_.COD_BARRAS_TALAO as COD3_0_0_,
associacao1_.COD_BARRAS_OPERADOR as COD4_0_0_,
associacao1_.COD_BARRAS_CADASTRO as COD5_0_0_,
associacao1_.ID_TALAO as ID16_0_0_,
associacao1_.DT_CADASTRO_SISTEMA as DT6_0_0_,
associacao1_.DT_CADASTRO_SUPERVISOR as DT7_0_0_,
associacao1_.DT_CADASTRO_OPERADOR as DT8_0_0_,
associacao1_.DT_DEVOLUCAO_OPERADOR as DT9_0_0_,
associacao1_.DT_DEVOLUCAO_SUPERVISOR as DT10_0_0_,
associacao1_.DT_PERDIDO as DT11_0_0_,
associacao1_.DT_SUSPENSO as DT12_0_0_
from
TALAO talaoto0_
left outer join
ASSOCIACAO associacao1_
on talaoto0_.ID_TALAO=associacao1_.ID_TALAO
where
talaoto0_.ID_TALAO=?


If i remove mapping from TalonTO:



It works very fast, i dont know why...

What im doing wrong and how can hibernate only generates one query at Associate?

Thanks

David.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic