Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate Issuing select statement even if FetchMode = Join

Tags:

hibernate

I have a userAccount entity mapped with a country entity . The country mapping in UserAccount class is like this

@ManyToOne(fetch=FetchType.EAGER) @Fetch(FetchMode.JOIN) @JoinColumn(name="f_country_id", nullable=true, insertable=false, updatable=false) private Country country; 

Even there is fetchmode defined as Join, hibernate fires a separate SQL Select to fetch countries.

like image 634
Manish Mudgal Avatar asked Mar 28 '11 10:03

Manish Mudgal


1 Answers

Remove the fetch=FetchType.EAGER. Eager fetching triggers cascading select statements.

like image 114
Satadru Biswas Avatar answered Sep 27 '22 18:09

Satadru Biswas