LazyInitialization / join fetch

#1

I have a survey that carries the tabla Items . A company has several items , a user charge and technical user also .
A specialty has several technical users .

Area A has a charge .

What happens :

When I click the Items table hibernate does all these other queries without me asking .

I have a survey that carries the tabla Items . Being a company that has multiple items , a user charge and technical user also .
A specialty has several technical users .

Area A has a charge .

What happens :

When I click the Items table hibernate does all these other queries without me asking .

`` `
Hibernate : select the item0_.codigo codigo1_3_ , item0_.aplicavel the aplicave2_3_ , item0_.area the area3_3_ , item0_.codigo_item the codigo4_3_ , item0_.criticidade the criticid5_3_ , item0_.data_item the data6_3_ , item0_.descricao the descrica7_3_ , item0_.codigo_empresa the codigo11_3_ , item0_.codigo_encarregado the codigo12_3_ , item0_.justificativa the justific8_3_ , item0_.status the status9_3_ , item0_.codigo_tecnico the codigo13_3_ , item0_.total_itens total10_3_ from the item item0_ limit ?
Hibernate : select the empresa0_.codigo codigo1_1_0_ , empresa0_.cnpj the cnpj2_1_0_ , empresa0_.data_fim the data3_1_0_ , empresa0_.data_ini the data4_1_0_ , empresa0_.bairro the bairro5_1_0_ , empresa0_.cep the cep6_1_0_ , empresa0_.cidade the cidade7_1_0_ , empresa0_.complemento the compleme8_1_0_ , empresa0_.logradouro the logradou9_1_0_ , empresa0_.numero the numero10_1_0_ , empresa0_.uf the uf11_1_0_ , empresa0_.iscricao_estadual the iscrica12_1_0_ , empresa0_.nome the nome13_1_0_ , empresa0_.nome_fantasia the nome14_1_0_ , empresa0_.segmento the segment15_1_0_ , empresa0_.sponsor the sponsor16_1_0_ , empresa0_ . totaItens totaIte17_1_0_ from the company where empresa0_ empresa0_.codigo = ?
Hibernate : select the usuario0_.codigo codigo1_6_4_ , usuario0_.codigo_area the codigo10_6_4_ , usuario0_.codigo_chefe the codigo11_6_4_ , usuario0_.email the email2_6_4_ , usuario0_.codigo_empresa the codigo12_6_4_ , usuario0_.codigo_especialidade the codigo13_6_4_ , usuario0_.login the login3_6_4_ , usuario0_.nome the nome4_6_4_ , usuario0_.permissao the permissa5_6_4_ , usuario0_.senha the senha6_6_4_ , usuario0_.tel_celular the tel7_6_4_ , usuario0_.tel_fixo the tel8_6_4_ , usuario0_.ramal the ramal9_6_4_ , area1_.codigo the codigo1_0_0_ , area1_.descricao the descrica2_0_0_ , usuario2_.codigo the codigo1_6_1_ , usuario2_ . codigo_area the codigo10_6_1_ , usuario2_.codigo_chefe the codigo11_6_1_ , usuario2_.email the email2_6_1_ , usuario2_.codigo_empresa the codigo12_6_1_ , usuario2_.codigo_especialidade the codigo13_6_1_ , usuario2_.login the login3_6_1_ , usuario2_.nome the nome4_6_1_ , usuario2_.permissao the permissa5_6_1_ , usuario2_.senha the senha6_6_1_ , usuario2_.tel_celular the tel7_6_1_ , usuario2_.tel_fixo the tel8_6_1_ , usuario2_.ramal the ramal9_6_1_ , empresa3_.codigo the codigo1_1_2_ , empresa3_.cnpj the cnpj2_1_2_ , empresa3_.data_fim the data3_1_2_ , empresa3_.data_ini the data4_1_2_ , empresa3_.bairro the bairro5_1_2_ , empresa3_.cep the cep6_1_2_ , empresa3_.cidade the cidade7_1_2_ , empresa3_.complemento the compleme8_1_2_ , empresa3_.logradouro the logradou9_1_2_ , empresa3_.numero the numero10_1_2_ , empresa3_.uf the uf11_1_2_ , empresa3_.iscricao_estadual the iscrica12_1_2_ , empresa3_.nome the nome13_1_2_ , empresa3_ . nome_fantasia the nome14_1_2_ , empresa3_.segmento the segment15_1_2_ , empresa3_.sponsor the sponsor16_1_2_ , empresa3_.totaItens the totaIte17_1_2_ , especialid4_.codigo the codigo1_2_3_ , especialid4_.descricao descrica2_2_3_ from the User usuario0_ left outer join on area area1_ usuario0_.codigo_area = area1_.codigo left outer join on User usuario2_ usuario0_.codigo_chefe = usuario2_.codigo left outer join company empresa3_ on usuario2_.codigo_empresa = empresa3_.codigo left outer join on specialty especialid4_ usuario2_.codigo_especialidade = especialid4_.codigo where usuario0_.codigo = ?
Hibernate : select count ( item0_.codigo ) from the col_0_0_ item item0_
Nov
`` `

This may be occurring due to not doing the fetch join?

If so should I do to all fields of List , ie OneToMany or should also be done for joins ?
Grateful.


This may be occurring due to not doing the fetch join?

If so should I do to all fields of List , ie OneToMany or should also be done for joins ?
Grateful.

#2

Are you using Hibernate? This is the ObjectDB forum not the Hibernate forum.

ObjectDB Support

Reply