In this post, I would like to take the time to write about @Query, which allows you to write queries directly in Java JPA Respository. JPQL Although JPA automatically generates queries for you, you may need to write your own queries in some circumstances. There are two ways to write queries directly in JPA: Written in JPQL written in plain SQL JPQL is a platform-independent, object-oriented query language defined as part of JPA . As a query language that can be used in JPA, JPQL needs to look at and write entity classes, while plain SQL looks at databases and writes them. The way to write queries directly in both JPQL and SQL is to use the @Query annotation in the same way. And you can distinguish whether it is written in JPQL or SQL by using the property called nativeQuery in the @Query annotation. nativeQuery = true → SQL nativeQuery = false (default) → JPQL Also, the method name can be written freely unlike the existing automatic generation method . I'll gen...
Let's learn together Tech Tips