I have two entities Outlet and products having one to many relationship as follows-
@Entity
public class Outlet{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
Long id;
@Fetch (FetchMode.SELECT)
@OneToMany(mappedBy = "outletProduct",fetch = FetchType.LAZY)
List<Product> products;
and
@Entity
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Long id;
Boolean isActive;
@ManyToOne
@JoinColumn(name = "outletId")
Outlet outletProduct;
Now i want Outlets where products isactive is true.
I am writing follwing JPQL for-
@Query("Select op From Outlet op join op.products pro where pro.isActive=1 order by op.id")
List<Outlet> findAllByVarietiesPriceTimePeriodIn( );
But i am still getting outlets with prodcuts isactive false. Please suggest.
I want to achieve result which will come from this sql query-
SELECT * FROM outlet join product on product.outlet_id= outlet.id where product.is_active=1 ;