A lightweight Python tool that compares JPA entity annotations between two folders (archive/ and actual/).
It detects differences in:
@Index(columnList = "...")@JoinColumn(name = "...")(and inside@JoinColumns({...}))
and produces a console report, plus CSV and JSON summary files.
✅ Compares entities file-by-file (.java)
✅ Ignores:
- Index names
- Index order
✅ Optional: ignore column order inside a single index
✅ Detects deleted/new join columns
✅ Outputs: - Human-readable console log
jpa_index_join_diff.jsonjpa_index_join_diff.csv
archive/CompanyLoan.java
@Table(name = "COMPANY_LOANS", indexes = {
@Index(name = "CL_KHR_LOANS_FK_IDX", columnList = "KHR_LOANS_FK"),
@Index(name = "CL_TABLE_FK_IDX", columnList = "TABLE_FK")
})
public class CompanyLoan {
@ManyToOne
@JoinColumn(name = "KHR_LOANS_FK")
private KhrLoan khrLoansFk;
}actual/CompanyLoan.java
@Table(name = "COMPANY_LOANS", indexes = {
@Index(name = "CL_TABLE_FK_IDX", columnList = "TABLE_FK"),
@Index(name = "CL_LOAN_FK_IDX", columnList = "LOAN_FK")
})
public class CompanyLoan {
@ManyToOne
@JoinColumn(name = "LOAN_FK")
private LOAN LOANFk;
}Output:
• CompanyLoan.java
❌ Missing indexes in ACTUAL (present in ARCHIVE):
- (KHR_LOANS_FK)
❌ New indexes in ACTUAL (not in ARCHIVE):
+ (LOAN_FK)
❌ Deleted joinColumns in ACTUAL (present before):
- KHR_LOANS_FK
❌ New joinColumns in ACTUAL:
+ LOAN_FK
Only uses Python standard libraries — no external install required.
(Optionally create a venv.)
python -m venv .venv
source .venv/bin/activate # Linux/Mac
# or
.venv\Scripts\activate # Windowspython compare_jpa_indexes_and_joins.py --archive ./archive --actual ./actualOptional flags:
--ignore-column-order→ ignores column order inside each index--out-prefix→ custom output name (default:jpa_index_join_diff)
Example:
python compare_jpa_indexes_and_joins.py --archive ./archive --actual ./actual --ignore-column-order --out-prefix result| File | Description |
|---|---|
jpa_index_join_diff.json |
Structured JSON summary |
jpa_index_join_diff.csv |
CSV-friendly diff table |
| console log | readable summary for human inspection |
- Python 3.8+
- Works on Linux, macOS, and Windows
- Fork the repo
- Create a feature branch
- Commit changes and run the tool locally
- Submit a Pull Request 🎉
MIT License — see LICENSE
Developed by ChatGPT vibecoding - instructed by Márton Soós
Inspired by real-world JPA entity maintenance workflows.