You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose we have a Product class, that has an ProductAttribute field. The ProductAttribute class has a value field and object with id.
public class Product {
private List<ProductAttribute> attributes;
}
public class ProductAttribute {
private String value;
private Attr attr;
}
public class Attr{
private Long id
}
I want to be able to search for all products that has in attributes (value="RTX 2080" AND attr.id=1) AND (value="RGB" AND attr.id=3) on the same persisted Product object. How can I achieve that?
I have tried things, with no success, like: http://localhost:8081/products/search?filter=((attributes.value:'RTX 2080' and attributes.attribute.id:'1') and (attributes.value:'RGB' and attributes.attribute.id:'3'))
but it makes only one join so hibernate makes somthing like select p1_0.id,p1_0.category_id,p1_0.description,(SELECT SUM(p.stock) FROM productsize p JOIN products_product_sizes pps on p.id = pps.product_sizes_id WHERE pps.product_id =p1_0.id),p1_0.title from products p1_0 where exists(select 1 from products_attributes a1_0 join productattributes a1_1 on a1_1.id=a1_0.attributes_id join attribute a2_0 on a2_0.id=a1_1.attribute_id where a1_1.value='RTX 2080' and a1_1.attribute_id=1 and a1_1.value='RGB' and a1_1.attribute_id=3 and p1_0.id=a1_0.product_id) offset ? rows fetch first ? rows only
The text was updated successfully, but these errors were encountered:
http://localhost:8081/products/search?filter=exists(attributes.value:'RTX 2080' and attributes.attribute.id:'1') and exists(attributes.value:'RGB' and attributes.attribute.id:'3')
I think that it would work that way. Feel free to reopen if not.
Suppose we have a Product class, that has an ProductAttribute field. The ProductAttribute class has a value field and object with id.
public class Product {
}
public class ProductAttribute {
}
public class Attr{
private Long id
}
I want to be able to search for all products that has in attributes (value="RTX 2080" AND attr.id=1) AND (value="RGB" AND attr.id=3) on the same persisted Product object. How can I achieve that?
I have tried things, with no success, like:
http://localhost:8081/products/search?filter=((attributes.value:'RTX 2080' and attributes.attribute.id:'1') and (attributes.value:'RGB' and attributes.attribute.id:'3'))
but it makes only one join so hibernate makes somthing like
select p1_0.id,p1_0.category_id,p1_0.description,(SELECT SUM(p.stock) FROM productsize p JOIN products_product_sizes pps on p.id = pps.product_sizes_id WHERE pps.product_id =p1_0.id),p1_0.title from products p1_0 where exists(select 1 from products_attributes a1_0 join productattributes a1_1 on a1_1.id=a1_0.attributes_id join attribute a2_0 on a2_0.id=a1_1.attribute_id where a1_1.value='RTX 2080' and a1_1.attribute_id=1 and a1_1.value='RGB' and a1_1.attribute_id=3 and p1_0.id=a1_0.product_id) offset ? rows fetch first ? rows only
The text was updated successfully, but these errors were encountered: