Skip to main content

Posts

Showing posts with the label Spring Boot

JPA Auditing: Persisting Audit Logs Automatically using EntityListeners

In my previous article Spring Data JPA Auditing: Saving CreatedBy, CreatedDate, LastModifiedBy, LastModifiedDate automatically , I have discussed why Auditing is important for any business application and how we can use Spring Data JPA automate it. I have also discussed how Spring Data uses JPA’s EntityListeners and callback methods to automatically update CreatedBy , CreatedDate , LastModifiedBy , LastModifiedDate properties. Well, here in this article I am going dig a little bit more and discuss how we can use JPA EntityListeners to create audit logs and keep information of every insert, update and delete operation on our data. I will take the File entity example from the previous article and walk you through the necessary steps and code portions you will need to include in our project to automate the Auditing process. We will use Spring Boot, Spring Data JPA (Because it gives us complete JPA functionality plus some nice customization by Spring), MySql to demonstrate this. We wi...

Spring Data JPA Auditing: Saving CreatedBy, CreatedDate, LastModifiedBy, LastModifiedDate automatically

In any business application auditing simply means tracking and logging every change we do in the persisted records which simply means tracking every insert, update and delete operation and storing it. Auditing helps us in maintaining history records which can later help us in tracking user activities. If implemented properly auditing can also provide us similar functionality like version control systems. I have seen projects storing these things manually and doing so become very complex because you will need to write it completely by your own which will definitely require lots of code and lots of code means less maintainability and less focus on writing business logic. But why should someone need to go to this path when both JPA and Hibernate provides Automatic Auditing which we can be easily configured in your project. And here in this article, I will discuss how we can configure JPA to persist CreatedBy, CreatedDate, LastModifiedBy, LastModifiedDate columns automatically for any ...

Custom implementation for a Spring Data Solr Repository

In this article we are going to write the our own implementation for Solr repository and add some custom methods to it, However I am going to cover every little details but you should have little bit idea of Apache Solr, Spring Boot Repositories to understand this article. Apache Solr is basically an open source web application built on top of Apache lucene search API but Solr provides lots of extra functionalities than lucene. You don't need to be a Java programmer to perform search on Solr it provides a cool user interface with help of its REST-like APIs, We can do approx everything on this UI without having any knowledge of programming with little bit configuration. Rather than this Solr also provides advanced and optimised full text search, integration with Apache UIMA and Apache Tika and lots more you can see them official website of solr. With initiations convention over configuration Spring introduced a new framework named Spring Boot, Spring Boot has a lots of advance thin...