0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Automating DTO creation with GitHub Copilot

0
Last updated at Posted at 2026-03-07

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

  1. Prepare an empty file in the package where your DTOs are placed.
  2. Paste the CREATE statement into GitHub Copilot and instruct it: “Generate a DTO corresponding to this CREATE statement.”
  3. 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.

日本語版

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?