Skip to content

Enhance Java packages for DTO and WebAuthn and tests - #62

Merged
hoangsonww merged 1 commit into
masterfrom
feat/enhance-java-packages
Jun 12, 2026
Merged

hoangsonww merged 1 commit into
masterfrom
feat/enhance-java-packages

Conversation

@hoangsonww

Copy link
Copy Markdown
Owner

This pull request removes several IDE-specific data source configuration and metadata files from the .idea directory. These files are typically generated by JetBrains IDEs (like IntelliJ IDEA) to store local database connection settings and schema metadata, and are not necessary to keep in version control.

Removed IDE data source configuration and metadata files:

Data source configuration:

  • Deleted .idea/dataSources.local.xml, which contained local database connection definitions and credentials.

Database metadata (for various data sources):

  • Removed schema and database metadata files for MySQL and PostgreSQL data sources, including files under .idea/dataSources/*/storage_v2/_src_/schema/ and .idea/dataSources/*/storage_v2/_src_/database/. These files stored local introspection data for schemas like information_schema, pg_catalog, public, mysql, performance_schema, and sys. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

This cleanup helps keep the repository free from unnecessary local or environment-specific files.

@hoangsonww hoangsonww added this to the v2.x.x - Stable Release milestone Jun 12, 2026
@hoangsonww hoangsonww self-assigned this Jun 12, 2026
Copilot AI review requested due to automatic review settings June 12, 2026 01:36
@hoangsonww hoangsonww added bug Something isn't working documentation Improvements or additions to documentation duplicate This issue or pull request already exists labels Jun 12, 2026
@hoangsonww hoangsonww added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers dependencies Pull requests that update a dependency file labels Jun 12, 2026
@netlify

netlify Bot commented Jun 12, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for employee-management-fullstack-system canceled.

Name Link
🔨 Latest commit c13344f
🔍 Latest deploy log https://app.netlify.com/projects/employee-management-fullstack-system/deploys/6a2b62be98a4ad0008662efc

@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
employee-management-fullstack-app Ignored Ignored Jun 12, 2026 1:37am

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@hoangsonww
hoangsonww merged commit ae0d9aa into master Jun 12, 2026
6 of 7 checks passed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request restructures the backend application, introducing Data Transfer Objects (DTOs) for validation, a global exception handler, and WebAuthn/Passkey authentication. Key feedback highlights critical improvements: in EmployeeService, calling entityManager.clear() should be avoided to prevent detaching managed entities; in DepartmentService, getDepartmentById should use standard lazy loading instead of eagerly fetching all employees to avoid performance bottlenecks; in GlobalExceptionHandler, unexpected exceptions should be logged rather than swallowed; and in JwtRequestFilter, redundant filter chain calls in the exception catch block should be simplified.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines 48 to 53
public Employee saveEmployee(Employee employee) {
return employeeRepository.save(employee);
Employee saved = employeeRepository.save(employee);
entityManager.flush();
entityManager.clear();
return employeeRepository.findByIdWithDepartment(saved.getId()).orElse(saved);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Calling entityManager.clear() inside a service method is highly discouraged in Spring/JPA applications. It detaches all currently managed entities from the persistence context. If this method is called within a larger transaction, any other entities loaded in that transaction will be detached, which can lead to unexpected LazyInitializationExceptions or prevent automatic dirty checking/updates. Since Employee has an EAGER fetch type for department, employeeRepository.save(employee) already returns the fully populated entity, making the flush, clear, and reload redundant.

  public Employee saveEmployee(Employee employee) {
    return employeeRepository.save(employee);
  }

Comment on lines 36 to 38
public Optional<Department> getDepartmentById(Long id) {
return departmentRepository.findById(id);
return departmentRepository.findByIdWithEmployees(id);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using findByIdWithEmployees(id) inside getDepartmentById eagerly loads all employees of the department. This method is used in EmployeeController to resolve the department reference when creating or updating an employee. If a department has a large number of employees, this will cause a significant performance bottleneck by loading all of them into memory unnecessarily. Instead, use the standard findById(id) method which loads the department lazily, and only fetch employees when explicitly required.

Suggested change
public Optional<Department> getDepartmentById(Long id) {
return departmentRepository.findById(id);
return departmentRepository.findByIdWithEmployees(id);
}
public Optional<Department> getDepartmentById(Long id) {
return departmentRepository.findById(id);
}

Comment on lines +145 to +152
@ExceptionHandler(Exception.class)
public ResponseEntity<Map<String, String>> handleGenericException(Exception ex) {

Map<String, String> error = new HashMap<>();
error.put("message", "An unexpected error occurred");

return new ResponseEntity<>(error, HttpStatus.INTERNAL_SERVER_ERROR);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The catch-all exception handler swallows the unexpected exception without logging it. This makes debugging production issues extremely difficult because the stack trace is completely lost. You should log the exception at the ERROR level before returning the generic error response to the client.

  @ExceptionHandler(Exception.class)
  public ResponseEntity<Map<String, String>> handleGenericException(Exception ex) {
    org.slf4j.LoggerFactory.getLogger(GlobalExceptionHandler.class).error(\"Unexpected error occurred\", ex);
    Map<String, String> error = new HashMap<>();
    error.put(\"message\", \"An unexpected error occurred\");
    return new ResponseEntity<>(error, HttpStatus.INTERNAL_SERVER_ERROR);
  }

Comment on lines +48 to +54
try {
username = jwtTokenUtil.extractUsername(jwt);
} catch (Exception e) {
// Invalid/expired/malformed token — continue unauthenticated
chain.doFilter(request, response);
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Calling chain.doFilter(request, response) and returning inside the catch block is redundant. If an exception is thrown, username remains null, the subsequent authentication block is skipped, and the execution naturally falls through to the end of the doFilterInternal method where chain.doFilter(request, response) is called. You can simplify this by catching the exception and doing nothing (or logging it at a debug level), letting the filter chain proceed naturally.

      try {
        username = jwtTokenUtil.extractUsername(jwt);
      } catch (Exception e) {
        // Invalid/expired/malformed token — continue unauthenticated
      }

@hoangsonww hoangsonww moved this from Done to In progress in Employee Management App Project Board Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation duplicate This issue or pull request already exists enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

2 participants