Posts

Showing posts from August, 2022

Data Auditing in Spring Data JPA

Image
  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.   Spring provides four annotations in the spring-data-commons module for auditing features.  @CreatedByrepresents the principal that created the entity containing the field. @CreatedDate represents the date the entity containing the field was created. @LastModifiedBy represents the principal that recently modified the entity containing the field. @LastModifiedDaterepresents the date the entity containing the field was recently modified. Besides the four mentioned annotations, Spring also provides @EnableJpaAuditing that aims enable auditing feature. In order to explain how the auditing feature works in Spring Data JPA, we should be known abou...

Custom Spring Initializer

Image
Typically, REST developers use Spring Initializr to create the initial setup.  This comes as a web based UI mainly which provides the ability to create a new Spring Boot project using dependencies available and download the project created as a zip. So we don’t have to create it from scratch. All the basic structure of the project is already there in this downloaded zip. Spring Initializer comes as IDE plugins.  Why do we need to create our own Spring Boot Server? In order for a large team to work on microservices architecture, it must constantly build Spring Boot projects / libraries. Having a custom spring initiator enables developers to generate projects / libraries where they don't have to worry about package name, project name conventions, etc. You can configure the dependency list to suit your needs by overriding or using the default dependency list. The project version, build tool type, Java version, project descriptions etc are definable, so there is no problem rememb...