Spring Boot

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 »

Derived Query Methods

A derived query method is a method you declare in a Spring Data repository interface, where Spring reads the method name and generates the SQL query for you. You write only the method signature, such as List<Student> findByDepartment(String department);, with no SQL and no method body. Spring splits the name into parts: the action (findBy),

Derived Query Methods Read More »

JPA Repository

JPA Repository is a Spring Data JPA feature that provides ready-made database operations for JPA entities without requiring developers to write boilerplate SQL, JDBC connection, or EntityManager code. By extending JpaRepository, a repository interface automatically receives methods for common CRUD operations such as saving, retrieving, updating, and deleting records. Spring Data JPA creates the required

JPA Repository Read More »

Entity Mapping

Entity Mapping is the process of mapping Java classes and their fields to relational database tables and columns using JPA annotations. A Java class is marked as an entity using @Entity, while @Table can be used to specify the database table name. The @Id annotation identifies the primary key, and @GeneratedValue can be used to

Entity Mapping Read More »

JPA and Hibernate

JPA (Java Persistence API) is a standard specification in Java that provides a simple way to map Java objects to relational database tables using Object-Relational Mapping (ORM). Instead of writing SQL queries manually as in JDBC, developers can work with Java classes and objects, while JPA handles the conversion between objects and database records. Hibernate

JPA and Hibernate Read More »

Spring Data JPA

DatabaseMetaData is a JDBC interface used to obtain information about the database, JDBC driver, tables, columns, and supported database features. It is obtained from a Connection object using the getMetaData() method. Using DatabaseMetaData, a Java program can dynamically inspect database information without directly querying system tables. This is useful for database administration, debugging, database migration

Spring Data JPA Read More »

Scroll to Top