0

I want to know how do we pass a query in spring JPA that has been prepared dynamically while program execution. The required query may vary according to the user input. So after framing the query manually using a for loop how do i execute this query ?

I have tried executing the query using the JDBC concept. but i want something more like :

@Query ( query_String)
public <return_type> filterNodes(String query_String);

Is this possible ?

4

1 回答 1

1

您草拟的方法不起作用。

根据您创建查询的方式,有多种选项可能适合您:

  • 示例查询非常有限,但有它的用途
  • 规范或其 Querydsl 等价物相当灵活,我希望它们适用于您的情况,但这只是猜测,因为您没有描述如何创建查询。
  • 如果一切都失败了,您可以编写一个自定义方法实现,将查询作为参数并使用 anEntityManager来执行它。
于 2018-06-05T09:29:32.530 回答