[英]does JPQL not have an * symbol?
@Repository
public interface ParticipantRepository extends CrudRepository<Participant,Integer> {
@Query("select e from Participant e WHERE e.event.venue =:venue")
List<Participant> getParticipantsByEventVenue(String venue);
}
As you can see here ^ I have to use e to represent the * symbol.正如您在这里看到的那样^我必须使用e来表示*符号。 Is that just how JPQL works? JPQL 就是这样工作的吗?
is there an * symbol in JPQL? JPQL 中有 * 符号吗?
Yes, it is particular syntax for JPQL.是的,它是 JPQL 的特殊语法。 But if you like to use native SQL query, it is also possible as follows:但是如果你喜欢使用原生的SQL查询,也可以如下:
@Repository
public interface ParticipantRepository extends
JpaRepository<Participant,Integer> {
@Query("select * from Participant e WHERE
e.event.venue =:venue",nativeQuery = true)
List<Participant> getParticipantsByEventVenue(String venue);}
also it is recommender to use JpaRepository instead of crudRepository.也推荐使用 JpaRepository 而不是 crudRepository。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.