我想从JPA中的表中选择行,我的查询参数可以为null。 因此,如果它为null,我想考虑该表中该属性的所有值。
这是我的代码:
@Query("SELECT art FROM ArtWork art INNER JOIN art.subjects subject "
+ "INNER JOIN art.styles style "
+ "INNER JOIN art.collections collection "
+ "INNER JOIN art.priceBuckets priceBucket "
+ " WHERE ((subject.title) in (:subjectList) "
+ "AND (style.title) in (:styleList)"
+ "AND (collection.title) in (:collectionList)"
+ "AND (priceBucket.title) in (:priceBucketRangeList)"
+ "AND (art.medium is NULL OR art.medium = :medium)"
+ "AND (art.orientation) LIKE:orientation)"
+ ")")
在代码if:medium为null然后我希望它搜索表中的所有媒体
由于