Skip to content

fix(pharmacy): GRN native SQL - wrong persistence unit name and case-sensitive table names #21085

@buddhika75

Description

@buddhika75

Bug Description

Two bugs in PharmacyGrnNativeSqlService (introduced in feat #9e55690e) prevent the GRN view from working:

Bug 1 — Wrong persistence unit name

@PersistenceContext(unitName = "ruhunuPU") references a non-existent persistence unit.
The application fails to deploy with:

Could not resolve a persistence unit corresponding to the persistence-context-ref-name
[com.divudi.service.pharmacy.PharmacyGrnNativeSqlService/em]

Fix: Change to unitName = "hmisPU".

Bug 2 — Hardcoded lowercase table names break case-sensitive MySQL

All table names in the native SQL header and items queries were hardcoded lowercase (bill, department, etc.). On deployments with lower_case_table_names=0 (e.g. local coop), MySQL stores tables as BILL, causing:

SQLSyntaxErrorException: Table 'coop.bill' doesn't exist

Fix: Extend the existing INFORMATION_SCHEMA table-name resolution (already used for PHARMACEUTICALBILLITEM) to cover all tables via a lazy per-instance cache (buildTableCache()).

Bug 3 — GRN search UI: empty Status column and oversized Actions column

  • Status column (shows "Cancelled" badge) is empty for active GRN lists → remove it.
  • Actions column (white-space:nowrap) is too wide for a single View button → narrow to 6em.

Files Changed

  • src/main/java/com/divudi/service/pharmacy/PharmacyGrnNativeSqlService.java
  • src/main/webapp/resources/pharmacy/search/grn.xhtml

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions