Category: fullstackdevelopment

  • What is “effectively final” in Java?

    Let’s say you don’t want a variable value to be changed once it is initialized. How to achieve this in Java? By declaring the variable as final. Now the variable becomes a constant and the compiler will complain if it is modified anywhere. There is one more concept of “final” in Java , which is…

  • Are we using mutable objects too much?

    By default any object you create in java is mutable. And so we end up using mutable objects more often. But Java team themselves suggest to use Immutable objects more. From https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html : Maximum reliance on immutable objects is widely accepted as a sound strategy for creating simple, reliable code One reason why developers wouldn’t…

  • How to create a secret in AWS Secrets Manager?

    Creating a secret in AWS Secret Manager is pretty straightforward. Here are the steps to follow: STEP1: Go to AWS Secrets Manager Once you register on AWS , login to the console and navigate to AWS Secret Manager Then click on Store a new secret: STEP2: Choose the type of secret and enter the secret…

  • How to read a JSON request inside a Spring Boot filter?

    Let’s say you are using a filter in your spring boot application. Spring boot (Spring Security) already internally uses many filters to filter requests coming to your application. If you are going to create a custom filter you can do so by implementing Filter interface from javax servlet package or by extending GenericFilterBean/ OncePerRequestFilter provided…

  • What is @MapsId used for in JPA/Hibernate? – Part II

    In the previous post , we saw how and why to use @MapsId in a One to One relationship. In this post , lets see how it comes handy in a One to Many relationship. Let’s take the same Musician entity as the parent object. Let’s take an Album entity as the child object. A…

  • What is @MapsId used for in JPA/hibernate? – Part 1

    @MapsId annotation. If you ever wondered what this annotation is for , here is an in depth analysis of it: When is this annotation used? It is used if the primary key of a child table is the same as the primary key of a parent table Why is this used? By specifying the annotation…

  • Java 21 – Pattern Matching for Switch

    Switch statement in java has gone through a rapid evolution since Java 7. You could compare only integers until Java 7. And then Java 8 allowed you to compare strings and enums as well. And then Java 12 introduced a flurry of new features: Java 13 later introduced yield keyword to be used instead of…

  • How to write REST APIs for specific environments in Spring Boot?

    Let’s say you want to write a REST API in Spring Boot and you also want it to be accessible only in specific environments , say development environment and not in test or production environments. How can you achieve this in Spring Boot? By using the @Profile annotation! Spring Boot has the provision to create…

  • How to call a REST API protected with SSL (https) from Spring Boot without importing the certificate into java keystore ?

    In the previous post we saw how to consume a REST API protected with SSL (HTTPS) by importing necessary SSL certificates into JVM keystore That serves fine if you have access to the JVM . In case if you don’t and want to bundle those certificates along with your application and use it to call…

  • How to call REST API protected with SSL (https) from Spring Boot ?

    Let’s say you want to invoke a REST API from your spring boot application. And it is protected with SSL. In other words you need an SSL certificate to access that application, else you won’t be given access to it. Your java keystore already has a lot of inbuilt certificates(In my local it is present…