Skip to content

Conversation

vishwab1
Copy link
Contributor

@vishwab1 vishwab1 commented Jul 31, 2025

πŸ“‹ Description

JIRA ID: AMM-1670

Please provide a summary of the change and the motivation behind it. Include relevant context and details.


βœ… Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • πŸ”₯ Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • πŸ›  Refactor (change that is neither a fix nor a new feature)
  • βš™οΈ Config change (configuration file or build script updates)
  • πŸ“š Documentation (updates to docs or readme)
  • πŸ§ͺ Tests (adding new or updating existing tests)
  • 🎨 UI/UX (changes that affect the user interface)
  • πŸš€ Performance (improves performance)
  • 🧹 Chore (miscellaneous changes that don't modify src or test files)

ℹ️ Additional Information

Please describe how the changes were tested, and include any relevant screenshots, logs, or other information that provides additional context.

Issue:
When the Redis session expires after 30 minutes, the system attempts to fetch the user details from the database. However, due to issues like incorrect field mappings (e.g., pan), lazy loading failures (m_UserLangMappings), and missing Redis refresh logic, the user object is not returned properlyβ€”resulting in incomplete or failed API responses.

Logs :
Screenshot from 2025-07-31 19-33-49

Fixes and Corrective Actions
1. Serialization Fixes (PAN, DOB, DOJ fields)
Issue: JSON serialization failed because field names didn’t match β€” e.g., "pan" in JSON vs pAN in Java class.

Fix:
Added @JsonProperty("pan"), @JsonProperty("dob"), and @JsonProperty("doj") to correctly map JSON fields during deserialization.

2. Lazy Loading Fixes (m_UserLangMappings)
Issue: @onetomany(fetch = FetchType.LAZY) mapping caused deserialization errors when Redis tried to deserialize outside an active Hibernate session:

could not initialize proxy - no Session

Fix:
Changed fetch type to EAGER to ensure complete serialization.

Refer:https://pmp.piramalswasthya.org/confluence/spaces/AMRIT/pages/96043113/AMM-1670+Production_ASSAM_Session+timeout+issue

Summary by CodeRabbit

  • New Features

    • User information now includes "pan", "dob", and "doj" fields in API responses.
  • Improvements

    • Enhanced language mapping persistence for user and language data.
    • Updated project version to 3.2.1.

Copy link
Contributor

coderabbitai bot commented Jul 31, 2025

Walkthrough

The changes update the Maven project version in the POM file, adjust JPA persistence annotations in the Language entity, and modify field annotations in the User entity to improve JSON serialization and JPA mapping. No changes were made to business logic or error handling.

Changes

Cohort / File(s) Change Summary
Maven Version Update
pom.xml
Updated project version from 3.1.0 to 3.2.1.
Language Entity JPA Mapping
.../userbeneficiarydata/Language.java
Removed @Transient from m_UserLangMappings, making it a persistent JPA field.
User Entity Annotations
.../users/User.java
Added @JsonProperty to pAN, dOB, dOJ; updated @OneToMany on m_UserLangMappings (removed mappedBy, set fetch to EAGER).

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant UserEntity
    participant LanguageEntity
    participant JPAProvider

    Client->>UserEntity: Request User data (JSON)
    UserEntity->>JPAProvider: Fetch m_UserLangMappings (EAGER)
    JPAProvider-->>UserEntity: Return UserLangMappings
    UserEntity-->>Client: Return JSON with "pan", "dob", "doj" fields

    Client->>LanguageEntity: Request Language data
    LanguageEntity->>JPAProvider: Fetch m_UserLangMappings (now persistent)
    JPAProvider-->>LanguageEntity: Return UserLangMappings
    LanguageEntity-->>Client: Return Language data with UserLangMappings
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A hop and a skip, a version anew,
The Language now keeps its mappings in view.
User fields gleam with JSON delight,
"pan", "dob", "doj" shining bright.
With eager fetching, the data flowsβ€”
A rabbit’s update, as everyone knows! πŸ‡βœ¨

Note

⚑️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


πŸ“œ Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between b2aecd8 and 3890a12.

πŸ“’ Files selected for processing (3)
  • pom.xml (1 hunks)
  • src/main/java/com/iemr/common/data/userbeneficiarydata/Language.java (0 hunks)
  • src/main/java/com/iemr/common/data/users/User.java (3 hunks)
πŸ’€ Files with no reviewable changes (1)
  • src/main/java/com/iemr/common/data/userbeneficiarydata/Language.java
🧰 Additional context used
🧠 Learnings (1)
src/main/java/com/iemr/common/data/users/User.java (2)

Learnt from: srishtigrp78
PR: #166
File: src/main/java/com/iemr/common/service/grievance/GrievanceHandlingServiceImpl.java:422-431
Timestamp: 2025-03-03T05:44:08.973Z
Learning: In the Common-API project, JsonNode from Jackson library has been found to not work properly for certain JSON parsing tasks, so JSONObject is preferred in those cases, particularly in the GrievanceHandlingServiceImpl class.

Learnt from: Zapper9982
PR: #258
File: src/test/java/com/iemr/common/controller/brd/BRDIntegrationControllerTest.java:60-60
Timestamp: 2025-07-06T15:21:25.699Z
Learning: Spring Boot's default Jackson configuration ignores unknown/extra properties during JSON deserialization in REST controllers, making tests for extra fields in JSON input unnecessary as the framework handles this gracefully by default.

πŸ”‡ Additional comments (5)
src/main/java/com/iemr/common/data/users/User.java (4)

31-31: LGTM!

The import of JsonProperty is correctly added to support the JSON property annotations used on fields later in the class.


138-140: LGTM!

Adding @JsonProperty("pan") ensures consistent lowercase JSON property naming, which is a good practice for API consistency.


142-148: LGTM!

Adding @JsonProperty annotations for "dob" and "doj" maintains consistent lowercase JSON property naming across date fields, improving API consistency.


80-82: Verify the unidirectional @onetomany mapping and EAGER fetch

I couldn’t find any code setting the user field on UserLangMapping or relying on the previous bidirectional association. Please manually confirm:

  • That UserLangMapping still defines its link back to User (e.g., a @ManyToOne on a user field) and isn’t managed elsewhere.
  • No service or DAO code invokes setUser(...) on UserLangMapping or assumes .getUser().getX() will work.
  • EAGER loading here doesn’t introduce performance regressions on large result sets.
  • Persisting or updating UserLangMapping entities still works as intended under this read-only association (updatable=false, insertable=false).
pom.xml (1)

9-9: LGTM!

Version bump from 3.1.0 to 3.2.1 appropriately reflects the data model changes made to the User entity and related components.

✨ Finishing Touches
  • πŸ“ Generate Docstrings
πŸ§ͺ Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch vb/develop-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share
πŸͺ§ Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vishwab1 vishwab1 changed the base branch from main to release-3.2.1 July 31, 2025 10:02
Copy link

@vishwab1 vishwab1 requested review from drtechie and vanitha1822 July 31, 2025 11:12
@vishwab1 vishwab1 merged commit 87e6629 into release-3.2.1 Aug 1, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants