In another article, I have introduced to Spring Cache Abstraction. Following that article, In this article, I am going to show you how to configure Ehcache in the Spring Boot application(similarly, you can do for non-spring application by adding more dependencies).
Before jumping to the code demo section, I want to have a quick introduction to Ehcache, spring-boot-autoconfigure module, and spring-context-support module. Going through these pieces should be great to understand more what I do in the code demo section.
Ehcache is an open-source, standards-based cache that boosts performance, offloads your database, and simplifies scalability. It’s the most widely-used Java-based…
Caching is well-known as the most approach to increase application performance. Caching helps reduce the cost of CPU expensive operations such as Fibonacci calculation. Besides CPU expensive operations, caching also helps reduce IO expensive operations such as reading files from disk. Unfortunately, efficiently applying cache into the application is no simple task.
Spring Framework provides cache implementation in the spring-context module with a simple cache store that is
ConcurrentHashMapif no cache library found on the classpath. Otherwise, in case we have included supported cache libraries in the classpath,
With the spring cache, It has many built-in annotations to manage cache…
In recent decade Mongodb rises to become of the most database used in the software industry. This database stands on top of document databases it provides the scalability and flexibility that you want with the querying and indexing that you need. Therefore, I would like to share how we can connect a spring application to MongoDB and execute basic accessing data operations.
Before jumping to code, I would like to introduce how does spring support MongoDB in basic.
Spring boot supports MongoDB integration through the
spring-boot-starter-data-mongodb module which already included
spring-data-mongodb modules. Each module has a different…
In order to increase the performance while accessing data from a database, we must consider applying the connection-pool. You can search to know how does it help to increase the performance. I already wrote an article about this here:
In this article, I would like to share how we use the HikariCP library in a Spring Boot application.
HikariCP is a lightweight connection-pool library. This library is also known as the fastest connection pool library. “Fast, simple, reliable, lightweight” are four words used to describe it. At the time I’m writing this article it has more than 63.3k …
Many systems require auditing and tracking the change in the persistence layer. It is really helpful to investigate problems related to the data. Data auditing typically answers these questions: when was it created, who was create the record, when was it created, who modified the record last and when was it modified last. In this article, we will learn how to implement auditing features.
By now, Spring provides four annotations in the spring-data-commons module for auditing features. They are:
@CreatedByrepresents the principal that created the entity containing the field.
@CreatedDaterepresents the date the entity containing the field was created.
Any good developers know that fetching large data then render the view or response within a single request is a bad idea for a high-performance application. So in this article, I would like to share with you how to do paging and sort data with Spring Data JPA. This article gives you a solution to handle the most popular feature in most applications such as displaying products in the e-commerce system.
Before going to the demo, I would like to share with you how Spring Data JPA supports developers for doing paging and sorting.
Spring Data JPA already provides many solutions that allow us querying data easier such as Query Method, Query Method, or four repository interface(
Repository). These features are powerful, which help me a lot when building an application with Spring Data JPA. But a lot of time we still need to custom query or method to meet expectations or requirements.
The class design diagram above indicates how we can create a custom repository in Spring Data JPA. We just need to let EmployeeRepository implement the custom interface and define the implementation for the customized repository. …
Version Control is very important to make sure any change in the source code should be recorded and allow us to recall a specific version later. Imagine we edit some lines of code then deploy it without full-test then the error occurs due to the changes, unfortunately, we forgot to make a backup of the old code. Now how do we can revert to the previous version? In order to avoid these problems, we need a version control system to record and keep track of all changes in our code.
A version control system allows us to revert a selected…
H2 database is an open-source in-memory database that can be easily embedded into Java application. H2 database provides a list of features such as Pure Java, memory mode, encrypted database, ODBC driver even full-text search. Its size approx around 2MB.
H2 database also provides a browser-based Console application to manage data.
In this article, we will learn about message term in Spring Integration
In order to loose coupling between components in a system, we typically apply the messaging system to achieve that aim. That requires a solid understanding of what is a message and some type of message for effective use for specific scenarios. So in this article, I would like to share the definition of the message, the structure of a message, and common types of messages in a messaging system.
As the spring integration reference document defined that “In Spring Integration, a message is a generic wrapper for any…
Software Engineer at Terralogic. Blogger and Amateur Investor