dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Intermediate
Nov 15, 2019

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


How to Pass Parameters in @Query

Passing parameters to an SQL query written via @Query can be done via @Param or via positional parameters:

// via @Param
@Query(value = "SELECT p FROM Product p WHERE p.department=:department")
List fetchByDepartment(@Param("department") String department);

// via positional parameters
@Query(value = "SELECT p FROM Product p WHERE p.department=?1")
List fetchByDepartment(String department);
Octavia Anghel
 
Thanks for your registration, follow us on our social networks to keep up-to-date