Database guide

From hmislk/hmis · View interactive version

Database guide is an AI agent skill from the GitHub repository hmislk/hmis. MySQL database development guide for the HMIS project. Use when working with database queries, SQL debugging, database schema investigation, MySQL performance tuning, credential management, or database connection troubleshooting.

How to use this skill

Skill file

MySQL Developer Guide

Security Policy

Common Database Operations

Structure Investigation

SHOW TABLES LIKE '%bill%';
DESCRIBE bill;
SHOW CREATE TABLE bill;
SELECT COUNT(*) FROM bill WHERE retired = 0;

JPQL Query Patterns

// Standard entity query
String jpql = "SELECT b FROM Bill b WHERE b.retired = false AND b.department = :dept";

// DTO constructor query (use findLightsByJpql)
String jpql = "SELECT new com.divudi.core.data.dto.MyDTO(b.id, b.name) FROM Bill b WHERE ...";
List<MyDTO> results = (List<MyDTO>) facade.findLightsByJpql(jpql, params, TemporalType.TIMESTAMP);

// Aggregate query
String jpql = "SELECT SUM(b.netTotal) FROM Bill b WHERE ...";

Performance Tips

for it (fast DTO-based report as the default, legacy report kept for

cross-check). See the performance-optimization skill.

Local Development Databases

Each developer machine may have different Payara JDBC pool names and JNDI names. Common local databases:

When a restored database has lowercase table names, it must be converted to uppercase before the app can use it. Generate and run the rename script:

SELECT CONCAT('RENAME TABLE `', table_name, '` TO `temp_', table_name, '`; ',
              'RENAME TABLE `temp_', table_name, '` TO `', UPPER(table_name), '`;')
FROM information_schema.tables
WHERE table_schema = '<db_name>' AND table_name != UPPER(table_name);

Then pipe the output into mysql for that database. See src/main/webapp/resources/sql/UpperCase.sql for reference (note: that file targets a specific schema — always generate fresh from the actual database).

Persistence Configuration

For complete reference, read developer_docs/database/mysql-developer-guide.md.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.