java.lang.ClassCastException:java.lang.String无法强制转换为java.lang.Long(Hibernate)

时间:2018-05-08 11:23:48

标签: java hibernate detachedcriteria in-subquery

我试图在hibernate中运行子查询,如下所示: -

DetachedCriteria cartProductIds = DetachedCriteria.forClass(UserCart.class,"usercart")
                                        .add(Restrictions.eq("is_deleted", false))
                                        .add(Property.forName("usercart.user_id").eq(Property.forName("search.userId")))
                                        .add(Property.forName("usercart.product_id").eq(Property.forName("search.productId")))
                                        .setProjection(Projections.property("product_id"));

List<SearchHistory> history=session.createCriteria(SearchHistory.class,"search")
                                .add(Restrictions.between("creationTime", startTime, Timings.getCurrentTime()))
                                .add(Restrictions.eq("notification_send", false))
                                .add(Subqueries.notIn("productId", cartProductIds))
                                .list();

但是在notIn子查询行中出现错误,显示为: -

java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long.

需要帮助来解决这个问题。谢谢!

0 个答案:

没有答案