hibernate - Spring JPA loads all associated properties despite marking them as FetchType.LAZY in entity class -


i using jpa + hibernate. following entity class:

@entity @table(name = "test_details") public class testdetailsentity implements serializable {      private static final long serialversionuid = 0007l;      @id     @generatedvalue(strategy = generationtype.identity)     @column(insertable = true, nullable = false, unique = true, updatable = true)     private integer id;       @column(name = "login_name", nullable = false, length = 100)     private string loginname;      @column(name = "login_pwd", nullable = false, length = 100)     private string loginpwd;      @manytoone(fetch = fetchtype.lazy)     @joincolumn(name = "supplier_code", referencedcolumnname = "supplier_code")     @foreignkey(name = "fk_test_details_supplier_code")     private supplierentity supplierentity;      @manytoone(fetch = fetchtype.lazy)     @joincolumn(name = "component_id1", referencedcolumnname="component_id1", insertable = false, updatable = false)     @foreignkey(name = "fk_test_exam_details_component_id")     private componententity componententity; } 

i have getter setter methods properties.

now in spring jpa, have repository as:

public interface testdetailsrepository extends jparepository<testdetailsentity, integer>  {     @transactional(readonly = true)     @query("from testdetailsentity testdetails  testdetails.supplierentity.suppliercode in ?1 ")     public list<testdetailsentity> gettestdetailsbysuppliercode(list<string> suppliercode); } 

now when call method service class in following way:

public list<testdetailsentity> gettestdetailsbysuppliercode(list<string> suppliercode)     {         return testdetailsrepository.gettestdetailsbysuppliercode(suppliercode);     } 

i can see 1 query being executed *testdetailsentit*ies. there sql queries being fired other associated properties after that, each of testdetailsentit(ies) fetched. not want additional queries fired, don't want associated properties fetched.

please help.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -