QuizzesJPQL Basics — Concept Check
intermediate
hibernate

JPQL Basics — Concept Check

Questions on JPQL Basics. JPQL is an entity-oriented query language; queries reference entity and field names (not table/column names), making them portable across DB vendors.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on JPQL Basics — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.You have an entity class 'Order' with fields 'id', 'customerId', and 'status'. Which JPQL query correctly selects all orders for a customer with ID 42 and status 'SHIPPED'?

    • ASELECT * FROM Order o WHERE o.customerId = 42 AND o.status = 'SHIPPED'
    • BSELECT o FROM orders o WHERE o.customer_id = 42 AND o.status = 'SHIPPED'
    • CSELECT o FROM Order o WHERE o.customer_id = :cid AND o.status = :status
    • DSELECT o FROM Order o WHERE o.customerId = :cid AND o.status = :status
  2. 2.A developer uses the following JPQL query: 'SELECT o FROM Order o JOIN o.customer c WHERE c.email = :email'. What is the purpose of the JOIN clause here?

    • ATo explicitly join tables using SQL syntax
    • BTo navigate the association between Order and Customer entities
    • CTo select only fields from the Customer entity
    • DTo apply a filter on the Order entity without any association
  3. 3.In Spring Data JPA, what must be included in a repository method with a JPQL UPDATE query?

    • A@Entity annotation on the method
    • B@Query annotation only
    • C@Param annotation for each parameter
    • D@Modifying and @Transactional annotations
  4. 4.Which statement about JPQL parameters is correct?

    • APositional parameters are preferred for readability
    • BNamed parameters are less readable than positional parameters
    • CNamed parameters are preferred for readability and required in Spring Data @Query
    • DJPQL does not support named parameters
  5. 5.A developer mistakenly writes a JPQL query using SQL column names instead of field names. What is the likely outcome?

    • AThe query will fail because JPQL requires entity field names
    • BThe query will execute correctly as JPQL supports SQL column names
    • CThe query will return partial results
    • DThe query will execute but with a performance penalty
  6. 6.A JPQL query 'SELECT o FROM Order o WHERE o.customerId = :cid' is used. What does 'o' represent in this query?

    • AA column alias for customerId
    • BA SQL table alias
    • CAn alias for the Order entity
    • DAn alias for the database
  7. 7.Which JPQL feature allows mapping query results directly to a DTO?

    • AGROUP BY clause
    • BSELECT * syntax
    • CJOIN FETCH clause
    • DSELECT new constructor expression