← Workshop

Workshop · Tool

SQL to Spring Data JPA

Paste a single-table SELECT and get the derived-query method, the repository interface, and a list of things to check. Joins and functions fall back to a suggested @Query.

Supported: one table, WHERE with =, <>, >, >=, <, <=, LIKE, IN, BETWEEN, IS NULL, ORDER BY, LIMIT, COUNT(*). Joins fall back to a @Query.

Derived query method

List<Policy> findTop20ByStatusAndPremiumAmountGreaterThanOrderByCreatedAtDesc(String status, BigDecimal premiumAmount);

Repository interface

public interface PolicyRepository extends JpaRepository<Policy, Long> {
    List<Policy> findTop20ByStatusAndPremiumAmountGreaterThanOrderByCreatedAtDesc(String status, BigDecimal premiumAmount);
}

Check these

  • Parameter types are guessed from the column names. Confirm them against your entity.

Runs entirely in your browser. Parameter types are guessed from column names, so confirm them against your entity before use.