下面是我的存储库方法
List<Shipment> findByProductCategoriesBetweenQuarter( Set<Category> categories, Quarter from, Quarter to)其中Category是一个实体,Quarter是@Embeddable,如下所示
class Quarter {
int year;
Quarters q; //Enum
}我想创建一个自定义存储库impl与@Query与下面的代表性查询
@Query("select s from Shipment s where Category in (categories) and Quarter between (from, to)")看起来@Query可以很好地处理原语,找不到一个可以帮助我实现上述情况的示例。
所以这里有几个问题: 1.这有可能吗? 2.如果可能,请提供一些参考资料。
PS:现在不能做QueryDSL。
发布于 2016-11-07 14:32:28
JPA将在数据库表中以int的形式存储Enum序号。
因此,您可以执行以下操作。
@Query("select s from Shipment s where Category in (categories) and Quarter between (from.ordinal(), to.ordinal())")https://stackoverflow.com/questions/40458548
复制相似问题