Reputation: 49
@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. Is that just how JPQL works?
is there an * symbol in JPQL?
Upvotes: 0
Views: 123
Reputation: 149
Yes, it is particular syntax for JPQL. But if you like to use native SQL query, it is also possible as follows:
@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.
Upvotes: 1