Question

I am trying following query to fetch data from tables.

from PostMessageUsers as pmu 
left join fetch pmu.atomByReceivedBy as recBy 
left join fetch recBy.smsusers as recByDtl
left join fetch recBy.profilePics as profilePic

Problem is that on executon it is executing two queries as follow

Hibernate: select postmessag0_.id as id8_0_, atom1_.id as id9_1_, smsusers2_.aid as aid39_2_, profilepic3_.pic_id as pic1_23_3_, postmessag0_.received_by as received2_8_0_, postmessag0_.shared_of as shared3_8_0_, postmessag0_.sent_by as sent4_8_0_, postmessag0_.author as author8_0_, postmessag0_.messageid as messageid8_0_, postmessag0_.adddate as adddate8_0_, postmessag0_.status as status8_0_, postmessag0_.deleted_time as deleted9_8_0_, atom1_.name as name9_1_, atom1_.type as type9_1_, atom1_.adddate as adddate9_1_, atom1_.status as status9_1_, atom1_.deldate as deldate9_1_, smsusers2_.mobno as mobno39_2_, smsusers2_.password as password39_2_, smsusers2_.fname as fname39_2_, smsusers2_.lname as lname39_2_, smsusers2_.mailid as mailid39_2_, smsusers2_.dob as dob39_2_, smsusers2_.gender as gender39_2_, smsusers2_.registerdate as register9_39_2_, smsusers2_.city as city39_2_, smsusers2_.mobnovarification as mobnova11_39_2_, smsusers2_.mailidvarification as mailidv12_39_2_, smsusers2_.first_login as first13_39_2_, smsusers2_.mail_subscription as mail14_39_2_, smsusers2_.time_zone as time15_39_2_, smsusers2_.reg_date as reg16_39_2_, profilepic3_.aid as aid23_3_, profilepic3_.profile_pic_path as profile3_23_3_, profilepic3_.small_pic_path as small4_23_3_, profilepic3_.adddate as adddate23_3_, profilepic3_.aid as aid9_0__, profilepic3_.pic_id as pic1_0__ from xrcwrn_sms.post_message_users postmessag0_ left outer join xrcwrn_sms.atom atom1_ on postmessag0_.received_by=atom1_.id left outer join xrcwrn_sms.smsusers smsusers2_ on atom1_.id=smsusers2_.aid left outer join xrcwrn_sms.profile_pic profilepic3_ on atom1_.id=profilepic3_.aid
Hibernate: select basicprofi0_.aid as aid12_0_, basicprofi0_.relationship_status as relation2_12_0_, basicprofi0_.about_me as about3_12_0_ from xrcwrn_sms.basic_profile basicprofi0_ where basicprofi0_.aid=?

How to resolve this problem so that only one query should be fired to fetch data?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top