'OR condition doesnt work properly in JPA Query
i have the following entities
class ProductUnitOfMessure
@ManyToOne
@JoinColumn(name="PRODUCT_ID")
private Product product;
@ManyToOne
@JoinColumn(name="VARIANT_ID")
private Variant variant;
class Product
@OneToMany(mappedBy = "product", fetch = FetchType.LAZY)
List<Variant> variants;
class Variant
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PRODUCT_ID")
private Product product;
Now when i run the query
select p from ProductUnitOfMeasures p where p.variant.sku=?1 or p.product.sku =?1 (sku of type String).
it return empty list, although there are some as per the below ProductUnitOfMessure table ProductUnitOfMeasures
when i only run select p from ProductUnitOfMeasures p where p.product.sku =?1 i get some values, why this is happening even though i use OR not AND ?
database is oracle
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
