Reputation: 89
I have this query presented below and I'd like to retrieve only some tProducts filtered out by some property name (let's say which is active or not, a boolean), how can I do that? Can somebody help?
value = "SELECT DISTINCT(t) FROM Trfi t " +
"LEFT JOIN FETCH t.trfiProductCollection tProducts " +
"LEFT JOIN FETCH tProducts.productModel pModel " +
"LEFT JOIN FETCH t.trfiPaymentCollection tPayment " +
"WHERE t.sedId IN (:sessionIds) ",
countQuery = "SELECT COUNT (DISTINCT t) FROM Trfi t " +
"JOIN t.trfiProductCollection tProducts " +
"JOIN tProducts.productModel pModel " +
"JOIN pModel.provider provider " +
"JOIN t.trfiPaymentCollection tPayment " +
"WHERE t.sedId IN (:sessionIds) "
)
List<Trfi> getTrfiListBySessionsId(@Param("sessionIds") List<Integer> sessionIds);
Upvotes: 0
Views: 295
Reputation: 16400
Does that not work for you?
value = "SELECT DISTINCT(t) FROM Trfi t " +
"LEFT JOIN FETCH t.trfiProductCollection tProducts " +
"LEFT JOIN FETCH tProducts.productModel pModel " +
"LEFT JOIN FETCH t.trfiPaymentCollection tPayment " +
"WHERE t.sedId IN (:sessionIds) and tProducts.active = :active",
countQuery = "SELECT COUNT (DISTINCT t) FROM Trfi t " +
"JOIN t.trfiProductCollection tProducts " +
"JOIN tProducts.productModel pModel " +
"JOIN pModel.provider provider " +
"JOIN t.trfiPaymentCollection tPayment " +
"WHERE t.sedId IN (:sessionIds) and tProducts.active = :active"
)
List<Trfi> getTrfiListBySessionsId(@Param("sessionIds") List<Integer> sessionIds, @Param("sessionIds") boolean active);
Upvotes: 1