Parent-side Hibernate collection does not contain any child record

I am facing strange issue while fetching or entities, the problem is i am able to get single child entity from the parent but when when tried to access the child collections i am not able to get.
Though from hiberate logs i can see that hibernate is loading the entities but when parent.getChild i am doing it is returning zero size collection.

I tried accessing the child collection seperately using JPQL, query is returning back the list but from reference receiver i am getting zero size list.
Products product=productsRepo.findOne(Id);
is getting me my entity product corresponding to id passed, but product is having child collectins by name Varients, when i tried to access product.getVarients() i am getting zero size list but when i checked the logs my child entities are getting loaded properly

**EBUG] 2018-07-17 13:17:33 - Collection found: [com.api.sweft.entity.Products.varients#10002], was: [<unreferenced>] (initialized)**

bellow logs shows child entities loaded in logs

 [DEBUG] 2018-07-17 13:17:34 - com.api.sweft.entity.ProductVarients{varientName=Color, product=com.api.sweft.entity.Products#10002, varientValue=Green, id=1}
 [DEBUG] 2018-07-17 13:17:34 - com.api.sweft.entity.ProductVarients{varientName=Size, product=com.api.sweft.entity.Products#10002, varientValue=null, id=2}

I also tried to get only child records by giving parent id, my JPQL query seems run fine and results also received, but the reference is still empty collections (not able to access)

@Query("SELECT PR FROM ProductVarients PR JOIN PR.product p WHERE p.sysId=:sysId")
List<ProductVarients> findVarientsByProduct(@Param("sysId") Long sysId);

calling above query from repo from service:

List<ProductVarients> varients = varientService.listVarientsForProduct(product.getSysId());

but in variable varients i am getting zero size collections.

Please help i am stuck at this point


Either you didn’t use mappedBy for the parent side as explained in this article.

Or, you didn’t synchronize both sides of the bidirectional association.