Frameworks

Sorting

Sorting orders database results by one or more fields, such as name, age or registration date, in ascending or descending order.It is used so users can see data in a meaningful order (A–Z, newest first, youngest first) without sorting it in Java code.Spring Data provides it through the Sort class, and a Sort can also […]

Sorting Read More »

Pagination

Pagination splits a large database result into small pages, so the API returns only a few records at a time instead of the whole table. It is used to cut response time, memory usage and network load, and to make lists easier to browse. Spring Data provides it through the Pageable interface, with PageRequest as

Pagination Read More »

Pagination, Sorting and Searching

Pagination, Sorting and Searching are essential data retrieval techniques used in web applications and REST APIs to handle large datasets efficiently. Instead of loading thousands of records into memory at once—which degrades performance, consumes excessive network bandwidth, and slows down client applications—these techniques allow clients to retrieve data incrementally, in a specific order, and filtered

Pagination, Sorting and Searching Read More »

Composite Keys

A composite key is a primary key made of two or more fields that together identify a record uniquely, such as (student_id, course_id). It is used when no single column identifies a row, most often in join tables like enrollments, where the same student can appear many times and the same course can appear many

Composite Keys Read More »

Many-to-Many Mapping

Many-to-Many mapping links records so that one record on either side can be associated with many records on the other side (one student takes many courses, one course has many students). It is used because a relational database cannot store this directly in two tables, so JPA creates a third table, called a join table,

Many-to-Many Mapping Read More »

One-to-One Mapping

A one-to-one mapping means one record in a table is linked to exactly one record in another table, such as one student and one student profile. In the database, one table holds a foreign key (here profile_id in students) that points to the other table, and a UNIQUE constraint makes sure it is never shared.

One-to-One Mapping Read More »

Entity Relationships

An entity relationship describes how two tables are connected in the database, and JPA lets you show that connection as a link between two Java classes. A Student belongs to a Department, and a Department has many students. In the database this is a foreign key column (department_id) in the students table. In Java, you

Entity Relationships Read More »

Native Queries

A native query is a plain SQL query, written with @Query(value = “…”, nativeQuery = true), that Spring Data sends to the database exactly as written. It uses real table and column names (students, marks), unlike JPQL, which uses entity and field names (Student, s.marks). It is used when JPQL is not suitable, such as

Native Queries Read More »

Custom Queries

A custom query is a query you write yourself with the @Query annotation above a repository method, for needs that a method name alone cannot express. The default language is JPQL, which looks like SQL but uses entity and field names (Student, s.department) instead of table and column names. When you need database-specific SQL, you

Custom Queries Read More »

Scroll to Top