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. …
Have you ever face a problem that you changing the entity field and then the application throw exception at runtime due to the change? If you have been facing that problem I think using type-safe queries might be a good choice.
When writing query statements we mostly use JPQL or native query and write literally in string.
I purposely wrote the wrong query but we got no warning from the compiler because it has no way to detect such errors. …
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.
Spring Data MongoDB provides a class named
MongoTemplate which allows developers to perform common operations with the MongoDB server such as adding documents, updating documents, deleting documents, or collections.
This article is the first part of CRUD document using MongoTemplate that shares a detailed explanation of inserting document process while insert document with MongoTemplate.
First, we have a new document to be inserted to Mongodb, If the collection of the document does not exist(created) the MongoDB will create the collection first then continue to perform the insert process.
If the inserted document omitted the _id field, the MongoDB driver automatically…
This annotation represents a MongoDB collection. It similars to Entity annotation of Java persistence API. We must be put this annotation at the class level. If the collection’s name different from the class name we can specify the name by using the collection property or value property.
The Field annotation used to represent a field in a collection. It is similar to the Column annotation in java persistence API but it does not have much property like
Many of us have known about the distributed system, right? It is the kind of software architecture that we distribute the application on multiple servers. It allows us to build high scalability and high reliability. The drawback is managing data consistency becomes more complex. And invalidate cache is one of the complex tasks too. Therefore in this article, I would like to share two caching approaches for a distributed system. Centralized Cache or Localized Cache.
The centralizing cache is mostly done by using cache servers such as Memcached or Redis. …
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.
We write about programming. We share about programming.