JPA Query处理NULL值参数

时间:2014-09-11 05:49:32

标签: java hibernate jpa

我想从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然后我希望它搜索表中的所有媒体

由于

0 个答案:

没有答案