Home » Tip Bank » Java
  • Comment on this Article
Language: Java
Expertise: Intermediate
Nov 15, 2019

WEBINAR:

On-Demand

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


Watch

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
 
Submit a Tip
Browse "Java" Tips
Browse All Tips
googlecode.com
htmlandcssbook.com