Posted on: June 24, 2025 Posted by: rahulgite Comments: 0

📘 Design Pattern Interview Scenarios (Monolith & Microservices)

✅ Scenario 1: Payment Gateway Integration using Factory Pattern 🧩 Problem Statement:An application needs to support various payment modes such as Credit Card, PayPal, UPI, and Net Banking. Instantiating all services eagerly is inefficient in terms of memory and performance. The application should only instantiate the required payment service based on the user’s choice at runtime. 🎯 Objective: 🛠️ Solution: Factory PatternThe Factory Pattern is ideal when the creation of…

Posted on: June 24, 2025 Posted by: rahulgite Comments: 0

JPA, Hibernate, and Transaction Scenarios

1. @Transactional Annotation Issues Problem: Changes are not reflected in the database despite using @Transactional. Reason 1: Calling from the Same Class Reason 2: Wrong Propagation Type Reason 3: No Exception Thrown (or Checked Exception) Reason 4: No Explicit Flush (rare in Spring Boot) Reason 5: Incorrect Isolation Levels Reason 6: Read-Only Transaction Reason 7: @EnableTransactionManagement Not Enabled 2. ID Generation Gaps Problem: Gaps in ID generation like 1, 10,…

Posted on: May 24, 2025 Posted by: rahulgite Comments: 0

Java 21 Features: Before vs After with Examples and Rationale

Java 21, released in September 2023, is a Long-Term Support (LTS) release that finalizes several preview features from Java 17–20 and introduces powerful new capabilities. This document explains each major feature in Java 21 by detailing: 1. String Templates (JEP 430 – Preview) What: Introduces template expressions to simplify and secure string composition. Why: Reduces errors from concatenation and formatting, improves code readability, and supports customizable templates. Before: Now: Benefit:…

Posted on: April 21, 2025 Posted by: rahulgite Comments: 0

JPA Scenario Questions 3

Question 1: Before: Why is JPA being called every time even though the cache is not expired and criteria haven’t changed? Issue: Even though the employee data is the same, JPA repository is still being called on every request. The caching layer (like Redis or Ehcache) is not being used properly, and there’s no database query optimization in place. The data is not being retrieved from the cache as expected.…

Posted on: April 21, 2025 Posted by: rahulgite Comments: 0

JPA Interview Question 2

How can we implement a REST endpoint using a GET request to filter Employee entities based on any of their fields, without adding all 100+ fields as request parameters, and further support field-level data sources dynamically without changing application code or application.yml? Answer: To achieve zero-code and zero-config dynamic filtering, we design a system where each field of an Employee can pull its data from different data sources or queries…

Posted on: April 21, 2025 Posted by: rahulgite Comments: 0

REST Interview Question

How can we implement a REST endpoint using a GET request to filter Employee entities based on any of their fields, considering the Employee class may have 100+ attributes, making individual @RequestParams impractical? Answer: To support dynamic filtering via a GET request without listing all 100+ fields as @RequestParam, we can use a single JSON-based query parameter (e.g., filter) and deserialize it into a filter object on the backend. This…

Posted on: April 21, 2025 Posted by: rahulgite Comments: 0

Java Scenario Question 1

Given a list of Employee objects, where an employee can appear multiple times due to designation changes, how can we use Java Streams to count the number of unique employees based on their most recent designation? Each Employee object contains: We want to ensure that for each employee, only the most recent record (based on modifiedDate) is considered for counting. Answer: We can solve this using Java Streams by following…

Posted on: April 21, 2025 Posted by: rahulgite Comments: 0

JPA Scenario Questions 1

We have an Employee class with the following structure: When a manager is terminated, we want to terminate all employees reporting to them. However, since reportingEmps is marked as LAZY fetch, we are encountering an exception when trying to access the reporting employees. What is the exception, and how can it be resolved? Answer: The exception being encountered is: This happens because the reportingEmps collection is lazily loaded, and you…

Posted on: April 5, 2025 Posted by: rahulgite Comments: 0

Angular Version-wise Feature Summary

Angular 2 (2016) Angular 4 (2017) Angular 5 (2017) Angular 6 (2018) Angular 7 (2018) Angular 8 (2019) Angular 9 (2020) Angular 10 (2020) Angular 11 (2020) Angular 12 (2021) Angular 13 (2021) Angular 14 (2022) Angular 15 (2022) Angular 16 (2023) Angular 17 (2023) Angular 20 (2024) Here are the key new features introduced in Angular 20: 1. Standalone Components as Default Description: Angular 20 promotes standalone components to…

Posted on: March 12, 2025 Posted by: rahulgite Comments: 0

Comprehensive Guide to Tree Algorithms

1. Tree Basics A tree is a hierarchical data structure consisting of nodes, where each node has a parent (except the root) and zero or more children. Trees are a type of graph with no cycles and a single connected component. Types of Trees: Tree Terminology: 2. Tree Traversal Algorithms 2.1 Inorder Traversal (Left, Root, Right) Description: Visits nodes in ascending order for a BST. Example Tree: Traversal Order: 1…