# jpa

Java Persistence API (JPA) is a Java application programming interface specification that describes the management of relational data in applications using Java Platform, Standard Edition and Java Platform, Enterprise Edition. It provides an object-relational mapping (ORM) facility for the Java language, allowing developers to interact with databases through the use of Java objects. JPA allows developers to easily persist and query data in a database, providing a simple and standardized approach to data persistence and management.

## All Niche Things about using JPA

| Title                                                                                                                       | Description                                                                                                                                                                                                                                                                                                                                                                                          |
| --------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Custom Sequences](jpa/boot-data-customsequence)                                                                            | <ul><li>Implements CustomSequence Generation like <code>ORD000001</code></li><li>Uses <a href="https://vladmihalcea.com/basejparepository-hypersistence-utils/">Custom Repository</a> instead of OOTB spring data repository</li><li>Logging SQL Statements using <code>DataSourceProxy</code></li><li>Connections Acquiring Optimization using <code>LazyConnectionDataSourceProxy</code></li></ul> |
| [Entity Auditing using envers](jpa/boot-data-envers)                                                                        | <ul><li>Version History and Auditing of db using spring data envers based on Hibernate Envers</li><li>Track who changed what and when</li><li>Revert or compare entity versions over time</li></ul>                                                                                                                                                                                                  |
| [Multiple DataSources](jpa/boot-data-multipledatasources)                                                                   | <ul><li>Connects to both PostgreSQL and MySQL databases</li><li>Uses Liquibase for Postgres and Flyway for MySQL migrations</li><li>Demonstrates data merging from multiple sources</li></ul>                                                                                                                                                                                                        |
| [Hibernate 2nd Level Cache](jpa/boot-hibernate2ndlevelcache-sample)                                                         | <ul><li>Implements Redis-based second-level caching</li><li>Reduces database round-trips for frequently accessed data</li><li>Demonstrates caching of entities and collections</li></ul>                                                                                                                                                                                                             |
| [JNDI Sample](jpa/boot-jndi-sample)                                                                                         | <ul><li>Demonstrates JNDI usage with embedded Tomcat</li><li>Uses Hikari DataSource for connection pooling</li></ul>                                                                                                                                                                                                                                                                                 |
| [JPA JOOQ Sample](jpa/boot-jpa-jooq-sample)                                                                                 | <ul><li>Combines JPA and JOOQ in a blog post management system</li><li>Demonstrates complex entity relationships (posts, comments, tags)</li><li>Shows both JPA and JOOQ-based data access patterns</li></ul>                                                                                                                                                                                        |
| [JPA Locks](jpa/boot-jpa-locks)                                                                                             | <ul><li>Demonstrates transaction isolation levels</li><li>Shows different propagation behaviors</li><li>Handles concurrent data access scenarios</li></ul>                                                                                                                                                                                                                                           |
| [Keyset Pagination](https://github.com/rajadilipkolli/my-spring-boot-experiments/blob/main/jpa/keyset-pagination/README.md) | <ul><li>Implements efficient pagination for large datasets</li><li><p>Includes implementations using:</p><ul><li>Spring Data JPA Window functions</li><li>Blaze Persistence for dynamic queries</li></ul></li></ul>                                                                                                                                                                                  |
| [MultiTenancy](jpa/multitenancy)                                                                                            | <ul><li><p>Implements multiple multi-tenancy strategies:</p><ul><li>Partition-based (Discriminator)</li><li>Schema-based</li><li>Database-based</li><li>Multi-DataSource with mixed strategies</li></ul></li></ul>                                                                                                                                                                                   |
| [Read Replica PostgreSQL](jpa/boot-read-replica-postgresql)                                                                 | <ul><li>Implements read/write splitting with PostgreSQL</li><li>Routes reads to replica and writes to primary</li><li>Uses LazyConnectionDataSourceProxy for runtime routing</li></ul>                                                                                                                                                                                                               |
