我如何将实体名称作为变量提供给 spring boot jpa 中的查询

how can i give entity name as a variable to a query in spring boot jpa

@Query("select c from :entity c )

BaseEntity findOne( @Param("value") String entity );

这会报错:-

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: : near line 1, column 15 [select c from :entity c ] at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:91) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]

http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query.spel-expressions

有你的答案,包括一个例子。

编辑:这不是您所问的 100%,但这是在 @Query 中操作实体的唯一可能方式。