Hi,
I am trying to define custom query for fetching object by id , bit it seem like it doesn't have effect when I define query on findOne() method in my repository interface (which extends CrudRepository)
I tried this:
bit it doesn't work, I get Place object with uninitialized child collection
If I define it on new method called findById and use same query on it, then it works.
Can somebody clarify this for me... Is defining custom query on existing CrudRepository methods not allowed or am I missing something?
Thanks
I am trying to define custom query for fetching object by id , bit it seem like it doesn't have effect when I define query on findOne() method in my repository interface (which extends CrudRepository)
I tried this:
Code:
@Query("SELECT p FROM Place p LEFT JOIN FETCH p.reviews WHERE p.id = ?1 ")
public Place findOne(Integer id);
If I define it on new method called findById and use same query on it, then it works.
Code:
@Query("SELECT p FROM Place p LEFT JOIN FETCH p.reviews WHERE p.id = ?1 ")
public Place findById(Integer id);
Thanks