java beginner
java beginner

Reputation: 49

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. Is that just how JPQL works?

is there an * symbol in JPQL?

Upvotes: 0

Views: 123

Answers (1)

Mani Movassagh
Mani Movassagh

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

Related Questions