我想根据用户选择在String变量中创建自定义查询,然后我想插入@Query并执行它 例如
class RequestResource
.
.
String query = "select r from Request r";
requestRepository.test(query);
.
.
class RequestRepository
.
.
@Query("?1")
List<Request> test(String query);
.
.
答案 0 :(得分:0)
我想我用这个来解决它
String finalQuery = "select r from Request r " + leftJoins + " where " + queryParams;
log.error("QUERY " + finalQuery);
TypedQuery<Request> query1 = em.createQuery(finalQuery, Request.class);