Skip to content

Commit

Permalink
feat: adds mapstruct to compiler plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli authored Oct 4, 2023
1 parent 7c95f8c commit 75f3054
Show file tree
Hide file tree
Showing 2 changed files with 457 additions and 412 deletions.
70 changes: 41 additions & 29 deletions jpa/boot-hibernate2ndlevelcache-sample/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
# boot-hibernate2ndlevelcache-sample

The Hibernate second level cache is a cache that is used to store the data that has been retrieved from the database. This cache is used to improve the performance of the application by reducing the number of trips to the database and providing quick access to frequently used data. The second level cache is typically implemented at the session factory level and is shared across all sessions within the factory. It is also configurable and can be enabled or disabled as needed. It is separate from the first level cache, which is associated with a session and only stores objects for the duration of that session. The second level cache is shared across sessions and can be configured to use various cache providers, such as Ehcache or Infinispan.

### Run tests

```shell
./mvnw clean verify
```

### Run locally

```shell
docker-compose -f docker/docker-compose.yml up -d
./mvnw spring-boot:run -Dspring-boot.run.profiles=local
```

### Useful Links

* Swagger UI: http://localhost:8080/swagger-ui.html
* Actuator Endpoint: http://localhost:8080/actuator
* Prometheus: http://localhost:9090/
* Grafana: http://localhost:3000/ (admin/admin)
* Kibana: http://localhost:5601/

### Notes

* We need to explicitly set the querycacheHint to customerqueries for enabling 2nd level cache
* This is enabled only for SessionFactory(i.e as soon as application is closed it will be deleted)
# boot-hibernate2ndlevelcache-sample

The Hibernate second level cache is a cache that is used to store the data that has been retrieved from the database. This cache is used to improve the performance of the application by reducing the number of trips to the database and providing quick access to frequently used data. The second level cache is typically implemented at the session factory level and is shared across all sessions within the factory. It is also configurable and can be enabled or disabled as needed. It is separate from the first level cache, which is associated with a session and only stores objects for the duration of that session. The second level cache is shared across sessions and can be configured to use various cache providers, such as Ehcache or Infinispan.

### Run tests

```shell
./mvnw clean verify
```

### Run locally

```shell
docker-compose -f docker/docker-compose.yml up -d
./mvnw spring-boot:run -Dspring-boot.run.profiles=local
```

### Useful Links

* Swagger UI: http://localhost:8080/swagger-ui.html
* Actuator Endpoint: http://localhost:8080/actuator
* Prometheus: http://localhost:9090/
* Grafana: http://localhost:3000/ (admin/admin)
* Kibana: http://localhost:5601/

### Notes

* We need to explicitly set the querycacheHint to customerqueries for enabling 2nd level cache
* This is enabled only for SessionFactory(i.e as soon as application is closed it will be deleted)

### **Caching Collections (One-Many & Many-Many Relations)**


Collection caching allows you to cache entire collections of associated entities. These collections can be part of your domain model, such as one-to-many or many-to-many relationships between entities.

Collection caching is valuable when dealing with associations between entities that are frequently loaded and where caching can lead to significant performance gains. When you enable collection caching, Hibernate caches entire collections, such as lists or sets, associated with an entity.

When Hibernate caches a collection, it doesn’t cache the entire collection of entities but rather caches the IDs of the entities contained in the collection.

* Caching only the IDs reduces memory usage compared to caching the entire collection of entities.
* When a collection is updated, only the relevant IDs need to be invalidated in the cache, rather than the entire collection. This minimizes cache invalidation overhead.
Loading

0 comments on commit 75f3054

Please sign in to comment.