Prerequisites
- Software development using Java and Spring Boot
- Database access implemented with MyBatis
- CREATE statements for the target tables are available in the database
Procedure
- Prepare an empty file in the package where your DTOs are placed.
- Paste the CREATE statement into GitHub Copilot and instruct it: “Generate a DTO corresponding to this CREATE statement.”
- Copilot will infer field definitions, data types, and annotations, then automatically generate the DTO.
Advanced Usage
- supplying SELECT statements that use INNER JOIN , or LEFT OUTER JOIN helps Copilot understand table relationships, enabling it to generate more accurate DTOs and mappings.
- You can also generate JavaDoc comments from column comments.
Simply instruct Copilot: “Generate JavaDoc comments based on the column comments.”
Notes
Using this approach helps prevent common mistakes such as incorrect data types or inconsistent naming when creating DTOs manually.
In environments like MyBatis, where SQL and Java structures closely correspond, CREATE statements effectively serve as specifications.
This allows Copilot to produce highly accurate suggestions, significantly improving development efficiency.
日本語版