As a java developer, I guest that you heard about the connection pool and might apply it to your system. Therefore in this article, we will learn how to configure C3P0 which is the most popular connection-pool library for java developers.
If you are a fan of Start War you might think C3P0 is this guy.
At my first time hearing about the connection pool and saw C3P0, I have made a mistake about the ZERO and O letter. I did not know and googling c3po and google show me this guy and I was confused. …
Let start with an example of saving order information. In many cases to store order information, we will have two tables let call Order and OrderLine. In consequently the system must save data for the order first then sort info of order line items. Now have to think about the case we save Order data successfully but the OrderLine failed. For this case, we have to rollback the order info to be not saved in the database to guarantee the consistency of the order information. In such problems, we have to use transactions.
In java or other languages, the developer…
Follow part one of the CRUD document using MongoTemplate series which shares about inserting documents, in this article, we will learn how to update documents by using MongoTemplate.
MongoTemplate provides a save method that allows updating documents. The diagram below shows how the
save method work in basic.
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…
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.
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.
Spring Cache Abstraction allows us to quickly make the application become cacheable. But it does not provide any real cache storage, it just provides cache features as
ConcurrentMap which provided by the JDK.
Now, in this article, we are going to configure Caffeine Cache as cache storage for the Spring Application. Before jumping to the coding section, let’s have a quick intro about Caffeine Cache and Spring Cache Abstraction.
Caffein is a high-performance Java 8 based caching library providing a near-optimal hit rate.
Caffeine Cache is similar to JDK
ConcurrentMap but is not quite the same. A JDK
In another article, I have introduced Spring Cache Abstraction. Following that article, In this article, I am going to show you how to configure Hazelcast in the Spring Boot application.
Before getting started with code implement, we should go through the basics of what is Hazelcast and Spring Cache Abstraction.
Hazelcast IMDG is an open-source distributed in-memory object store supporting a wide variety of data structures.
You can use Hazelcast IMDG to store your data in RAM, spread and replicate it across your cluster of machines, and perform computations on it. …
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…
We write about programming. We share about programming.