JPA Queries
JPA queries: method name derivation, @Query with JPQL, native queries, pagination, sorting
1What is JPQL?
What is JPQL?
Respuesta
JPQL (Java Persistence Query Language) is an object-oriented language that queries JPA entities rather than database tables. Unlike native SQL, JPQL uses class and property names, which maintains object abstraction and facilitates portability across different database systems. JPQL should be used by default unless specific SQL features are required.
2Which annotation allows executing a custom JPQL or SQL query?
Which annotation allows executing a custom JPQL or SQL query?
Respuesta
@Query annotation allows defining custom queries directly in Spring Data JPA repositories. It can contain JPQL by default or native SQL if the nativeQuery attribute is set to true. This annotation offers more flexibility than query methods derived from method names, especially for complex queries with joins or subqueries.
3How to bind a method parameter to a @Query?
How to bind a method parameter to a @Query?
Respuesta
@Param annotation allows explicitly naming parameters used in @Query queries. This approach is more readable and robust than using indexed positions, especially during code refactoring. The annotation is mandatory for named parameters in JPQL and recommended even for native SQL queries to improve maintainability.
In JPQL, which clause allows filtering results?
What is the main difference between JPQL and native SQL?
+27 preguntas de entrevista
Otros temas de entrevista Spring Boot
Spring Core - IoC & DI
Spring Boot Auto-Configuration
Spring Boot Starters
Application Properties & YAML
Logging with SLF4J & Logback
Spring Boot DevTools
Spring MVC Basics
Spring REST Controllers
Request & Response Handling
Exception Handling
Bean Validation
Spring Data JPA Basics
JPA Entities & Relationships
Spring Data Repositories
Spring Security Basics
Spring Boot Actuator
Unit Testing with JUnit & Mockito
Spring Boot Testing
Profiles & Environment
RestTemplate & WebClient
Async & Scheduling
Caching with Spring
Spring WebFlux (Reactive)
Spring Transactions
Advanced Authentication & Authorization
JWT & Stateless Security
OAuth2 & Authorization Server
Spring Boot & Docker
Microservices with Spring
Spring Cloud Config
Performance Optimization
GraalVM Native Images
Domina Spring Boot para tu próxima entrevista
Accede a todas las preguntas, flashcards, tests técnicos, ejercicios de code review y simuladores de entrevista.
Empieza gratis