Login / Register |
10 Years Experience WebService With Springboot and Angular in Deloitte - US
#webservice #microservices #microservice #angular #springboot #fullstack-developer #Deloitte #deloitte #USA #california #hibernate #agile #waterfall #database #tuning
Posted by TechElliptica at 23 Oct 2025 ( Day(s) Before)
as you said you are working in agile methodology but in this project we are working in waterfall model, how will you manage a requirement in waterfall i give you a requirement ?


While I have extensive experience working in Agile environments, I fully understand and can adapt to the Waterfall model.


If I receive a requirement in a Waterfall project,


I would begin by thoroughly analyzing the requirement during the Requirements Gathering phase, ensuring all details and expectations are clearly documented and signed off in Software Requirements Specification (SRS).
Next, I would move to the Design phase, where I would create detailed technical specifications, architecture diagrams, and database designs that align with the requirement as High-Level Design (HLD) and Low-Level Design (LLD).
Once the design is finalized, I would proceed to the Implementation phase, writing clean, modular, and maintainable code based strictly on the design specifications.
After development, I would engage in the Testing phase, conducting unit testing followed by system and integration testing, ensuring the requirement is fully met without defects. I would document all results and address any issues in coordination with the QA team.
Finally, during the Deployment and Maintenance phases, I would support the deployment process, provide post-release support, and ensure the application performs reliably in production.


The key to success in the Waterfall model is disciplined documentation, clear communication, and strict adherence to each phase before moving to the next — and I am fully capable of following that structured approach.


Most of the time requirement is fixed in waterfall, but sometime if we have late changes in requirements in waterfall, I handle changes methodically by first assessing the impact of the change on the existing design, code, timeline, and cost. I then document the change request clearly and communicate it to the relevant stakeholders, including project managers and business analysts. If the change is approved through the formal change control process, I ensure that the updates are reflected in all relevant documentation and that any affected phases—such as design, development, and testing—are revised accordingly. My focus remains on maintaining traceability, avoiding scope creep, and ensuring that the quality and timelines are preserved as much as possible within the Waterfall structure.

You are working in Restful api, tell me if you are developing a restful services, what step you will follow ?

Well there are many design process to develop an restful api but i am using springboot to develop restful api


usually i follow below process



1 - Create Project


Create a project in Maven/Gradle with all required dependencies.



2 - Define the Entity Class (Model Layer)


import jakarta.persistence.*;

@Entity
public class Employee {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String name;
private String department;
private Double salary;

// Getters and Setters
}


3 - Create the Repository Interface


import org.springframework.data.jpa.repository.JpaRepository;

public interface EmployeeRepository extends JpaRepository<Employee, Long> {
// Custom query methods (if needed)
}



4 - Create the Service Layer


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;

@Service
public class EmployeeService {

@Autowired
private EmployeeRepository repository;

public List<Employee> getAllEmployees() {
return repository.findAll();
}

public Optional<Employee> getEmployeeById(Long id) {
return repository.findById(id);
}

public Employee saveEmployee(Employee emp) {
return repository.save(emp);
}

public void deleteEmployee(Long id) {
repository.deleteById(id);
}
}



5 - Create the REST Controller


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/employees")
public class EmployeeController {

@Autowired
private EmployeeService service;

@GetMapping
public List<Employee> getAll() {
return service.getAllEmployees();
}

@GetMapping("/{id}")
public Employee getById(@PathVariable Long id) {
return service.getEmployeeById(id).orElse(null);
}

@PostMapping
public Employee create(@RequestBody Employee emp) {
return service.saveEmployee(emp);
}

@PutMapping("/{id}")
public Employee update(@PathVariable Long id, @RequestBody Employee emp) {
emp.setId(id);
return service.saveEmployee(emp);
}

@DeleteMapping("/{id}")
public void delete(@PathVariable Long id) {
service.deleteEmployee(id);
}
}


6 - Configure application.properties


spring.datasource.url=jdbc:mysql://localhost:3306/testdb
spring.datasource.username=root
spring.datasource.password=your_password

spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true



Suppose you have multiple database, how will you handle this in your project ?

We are using multiple databases in my project to perform different actions

Our primary database is MySQL-based and gives us all the information regarding the Base Component

The secondary database is also MySQL, but it is present on another server for logging purposes.


1. Define two DataSources in application.properties


# Primary DataSource (default)
spring.datasource.url=jdbc:mysql://localhost:3306/primary_db
spring.datasource.username=root
spring.datasource.password=pass
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

# Secondary DataSource (custom)
secondary.datasource.url=jdbc:mysql://localhost:3306/secondary_db
secondary.datasource.username=root
secondary.datasource.password=pass
secondary.datasource.driver-class-name=com.mysql.cj.jdbc.Driver


2. Create Entity Packages


Separate your entities:

  1. Primary DB entities - com.example.primary.entities
  2. Secondary DB entities - com.example.secondary.entities

This step is quite important because based on these package only Entity Manager able to map correct database.




3. Configure Primary DataSource (@Primary)


@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
basePackages = "com.example.primary.repositories",
entityManagerFactoryRef = "primaryEntityManagerFactory",
transactionManagerRef = "primaryTransactionManager"
)
public class PrimaryDBConfig {

@Primary
@Bean(name = "primaryDataSource")
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}

@Primary
@Bean(name = "primaryEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
EntityManagerFactoryBuilder builder,
@Qualifier("primaryDataSource") DataSource dataSource) {
return builder
.dataSource(dataSource)
.packages("com.example.primary.entities")
.persistenceUnit("primary")
.build();
}

@Primary
@Bean(name = "primaryTransactionManager")
public PlatformTransactionManager transactionManager(
@Qualifier("primaryEntityManagerFactory") EntityManagerFactory emf) {
return new JpaTransactionManager(emf);
}
}



4. Configure Secondary DataSource


@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
basePackages = "com.example.secondary.repositories",
entityManagerFactoryRef = "secondaryEntityManagerFactory",
transactionManagerRef = "secondaryTransactionManager"
)
public class SecondaryDBConfig {

@Bean(name = "secondaryDataSource")
@ConfigurationProperties(prefix = "secondary.datasource")
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}

@Bean(name = "secondaryEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
EntityManagerFactoryBuilder builder,
@Qualifier("secondaryDataSource") DataSource dataSource) {
return builder
.dataSource(dataSource)
.packages("com.example.secondary.entities")
.persistenceUnit("secondary")
.build();
}

@Bean(name = "secondaryTransactionManager")
public PlatformTransactionManager transactionManager(
@Qualifier("secondaryEntityManagerFactory") EntityManagerFactory emf) {
return new JpaTransactionManager(emf);
}
}


5. Use Repositories Normally

Just inject and use your repositories like normal:

@Autowired
private EmployeeRepository employeeRepo; // From primary DB

@Autowired
private AuditLogRepository auditRepo; // From secondary DB



so


To handle multiple databases in Hibernate/JPA, I define separate DataSource, EntityManagerFactory, and TransactionManager beans for each DB, configure their respective entity and repository packages, and use Spring’s @EnableJpaRepositories to bind them properly.


How will handle EntityManagerFactory in your spring-boot project ?


This pattern is commonly used to manage multiple databases in a Spring Boot application. By defining separate configurations with dedicated EntityManagerFactory, DataSource, and TransactionManager beans, we ensure that each database is cleanly separated and independently managed. Through the use of @EnableJpaRepositories, we bind specific packages of repositories to their corresponding database configurations. This allows Spring to handle each persistence context correctly behind the scenes, ensuring reliable data access and transaction management across multiple databases.


Here is a basic implementation


@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
basePackages = "com.example.primary.repositories",
entityManagerFactoryRef = "primaryEntityManagerFactory",
transactionManagerRef = "primaryTransactionManager"
)
public class PrimaryDBConfig {

@Primary
@Bean(name = "primaryDataSource")
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}

@Primary
@Bean(name = "primaryEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
EntityManagerFactoryBuilder builder,
@Qualifier("primaryDataSource") DataSource dataSource) {
return builder
.dataSource(dataSource)
.packages("com.example.primary.entities")
.persistenceUnit("primary")
.build();
}

@Primary
@Bean(name = "primaryTransactionManager")
public PlatformTransactionManager transactionManager(
@Qualifier("primaryEntityManagerFactory") EntityManagerFactory emf) {
return new JpaTransactionManager(emf);
}
}


basePackages will point to entity repository package so that spring boot initializer can easily map it.
@Primary annotation and Bean name will give an alias which will help our datasource in repository class
Configuration properties with prefix will take information from application.properties and connected based on property provided.



How will you set relationship in hibernate ?

To set relationships in Hibernate (or JPA), you define associations between entity classes using annotations like @OneToOne, @OneToMany, @ManyToOne, and @ManyToMany.

These annotations help Hibernate understand how your entities are related in the database and how to manage those relationships.


1. One-to-One


Example: One Employee has one Address


@Entity
public class Employee {
@Id
private Long id;

@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "address_id") // FK in Employee table
private Address address;
}

@Entity
public class Address {
@Id
private Long id;

private String city;
}



2. One-to-Many / Many-to-One


Example: One Department has many Employees


@Entity
public class Department {
@Id
private Long id;

private String name;

@OneToMany(mappedBy = "department", cascade = CascadeType.ALL)
private List<Employee> employees;
}


@Entity
public class Employee {
@Id
private Long id;

private String name;

@ManyToOne
@JoinColumn(name = "department_id")
private Department department;
}




3. Many-to-Many


Example: One Student can enroll in many Courses, and each Course can have many Students.


@Entity
public class Student {
@Id
private Long id;

@ManyToMany
@JoinTable(
name = "student_course",
joinColumns = @JoinColumn(name = "student_id"),
inverseJoinColumns = @JoinColumn(name = "course_id")
)
private List<Course> courses;
}
@Entity
public class Course {
@Id
private Long id;

private String title;

@ManyToMany(mappedBy = "courses")
private List<Student> students;
}



Key Annotations & Concepts


Annotation

Description

@OneToOne

One-to-one relationship

@OneToMany

One-to-many relationship (parent side)

@ManyToOne

Many-to-one relationship (child side)

@ManyToMany

Many-to-many relationship

@JoinColumn

Defines foreign key column

@JoinTable

Used for many-to-many join tables

cascade = CascadeType.ALL

Propagate changes (like save/delete)

mappedBy

Used on inverse side to avoid circular mapping





Suppose if i have 2 table, one table has foreign relation with other. If i want to delete data from table1 then will it delete data from table2 ?
By default, Hibernate does NOT delete child records when you delete the parent — unless you explicitly configure it to do so using the cascade attribute.


How to Enable Child Deletion Automatically


In the Parent Entity, you must set:

@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Child> children;


Explanation:


  1. cascade = CascadeType.ALL: Allows Hibernate to cascade operations like persist, remove, etc.
  2. orphanRemoval = true: Tells Hibernate to delete child records if they are no longer associated with the parent.


With this setup, deleting the parent will also delete the child records.



If You try Without Cascade/OrphanRemoval


If you don't use cascade = REMOVE or CascadeType.ALL, and try to delete the parent, Hibernate will throw a constraint violation error (foreign key still exists in the child table).


In Angular, How will you consume this Rest api also how will you show both table data in UI ?


Accessing both the parent and child table data in an Angular component.

We can implement below step


1. Define Models (Interfaces)


// department.model.ts
export interface Employee {
id: number;
name: string;
salary: number;
}

export interface Department {
id: number;
name: string;
employees: Employee[]; // child data
}



2. Create Angular Service to Call API


// department.service.ts
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Department } from './department.model';
import { Observable } from 'rxjs';

@Injectable({
providedIn: 'root'
})
export class DepartmentService {
private apiUrl = 'http://localhost:8080/api/departments'; // Your REST API endpoint

constructor(private http: HttpClient) {}

getDepartments(): Observable<Department[]> {
return this.http.get<Department[]>(this.apiUrl);
}
}



3. Consume the Service in Component


// department.component.ts
import { Component, OnInit } from '@angular/core';
import { DepartmentService } from './department.service';
import { Department } from './department.model';

@Component({
selector: 'app-department',
templateUrl: './department.component.html'
})
export class DepartmentComponent implements OnInit {
departments: Department[] = [];

constructor(private departmentService: DepartmentService) {}

ngOnInit(): void {
this.departmentService.getDepartments().subscribe((data) => {
this.departments = data;
});
}
}



4. Display Data in HTML Template


<!-- department.component.html -->
<div *ngFor="let dept of departments">
<h2>{{ dept.name }}</h2>
<ul>
<li *ngFor="let emp of dept.employees">
{{ emp.name }} - ₹{{ emp.salary }}
</li>
</ul>
<hr />
</div>


Provide me with an example where you did database performance tuning ?


In one of my recent projects for a government client (WISDot), we had a module that generated real-time reports from a large dataset — involving multiple joins between employee, project, and audit tables. The performance started to degrade significantly as data grew, especially under concurrent users.


Problem Identified:


  1. Page load time for report generation exceeded 10 seconds.
  2. SQL queries were doing full table scans.
  3. N+1 query issue was present due to lazy loading of associated entities in Hibernate.
  4. No proper indexing on frequently filtered columns.
  5. Unoptimized use of DISTINCT, IN clauses, and unnecessary JOINs.


Actions Taken:


1. Analyzed Slow Queries Using EXPLAIN PLAN & Hibernate Logs

  1. Identified which queries had poor execution plans.
  2. Enabled Hibernate SQL logging to trace inefficient queries.


2. Resolved N+1 Problem

  1. Used Hibernate's @EntityGraph and JOIN FETCH in JPQL:
@Query("SELECT d FROM Department d JOIN FETCH d.employees WHERE d.id = :id")
Department getDepartmentWithEmployees(@Param("id") Long id);


3. Created Proper Indexes

  1. Added indexes on columns used in WHERE, JOIN, and ORDER BY:
CREATE INDEX idx_emp_department_id ON employee(department_id);


4. Used Pagination

  1. Replaced full data fetch with Pageable:
Page<Employee> findByDepartmentId(Long deptId, Pageable pageable);


5. Refactored Queries

  1. Rewrote heavy nested queries using CTEs (Common Table Expressions) for better clarity and optimization.
  2. Reduced unnecessary joins and columns in SELECT clause.


6. Analyzed with SonarQube & Query Profiler

  1. Used SonarQube and database profiling tools to track performance metrics and ensure query complexity was reduced.



Results:


  1. Reduced average report generation time from 10+ seconds to under 2 seconds.
  2. CPU utilization decreased due to lighter DB load.
  3. Query performance improved by over 70%.
  4. Application became responsive even with 10,000+ records and multiple users.


Well, as this was a basic screening round.

I am done with my question.

Do you have any questions for me

Well, I only asked. What will be the next step ?



but you can ask below questions (ask only 1 or 2 questions)


What are the next steps after this round?
Will there be any hands-on technical rounds or coding assessments in the next stages?
Is there a timeline you’re aiming for to close this position?


What does a typical day or week look like for someone in this QA automation role?
Which testing tools and frameworks are most commonly used by your QA team?
How is the QA team structured? Will this role involve more individual work or team collaboration?
Is there a balance between manual and automation testing, or is the focus mostly on automation?
How large is the current QA automation suite, and how often is it maintained or updated?
How closely does the QA team work with developers and product owners?
Are there regular grooming or sprint planning sessions that QA participates in?
Is there a dedicated DevOps or SRE team, or does QA also participate in deployments and monitoring?
Does the company support learning or certification opportunities in QA, cloud, or DevOps?
What kind of growth path is there for QA professionals in this organisation?
Are there opportunities to move into roles like QA lead, SDET, or even DevOps/SRE from this position?
What vision team is having with automation testing in a feature with AI-ML tools