
Dto Creator
Generate Java DTO boilerplate—constructors, equals/hashCode—with Hibernate-aware patterns while mapping entity fields in a Spring project.
Install
npx skills add https://github.com/amplicode/spring-skills --skill dto-creatorWhat is this skill?
- Emits all-args constructors with project-aligned indentation from entity attribute types and names
- When isMutable=true, always generates both no-args and all-args constructors (hard rule in skill defaults)
- Immutable path (isMutable=false) emits a single all-args constructor only
- Documents equals()/hashCode() Hibernate proxy variant as a separate insert pattern after getters/setters
- Constructor parameters stay on one line with a blank line between no-args and all-args in the mutable case
Adoption & trust: 1 installs on skills.sh; 54 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
Recommended Skills
Journey fit
DTO classes are authored during backend implementation when exposing or transferring domain data, not during ideation or launch. Inserts constructors and equality methods into class bodies as part of server-side model work alongside entities and APIs.
Common Questions / FAQ
Is Dto Creator safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Dto Creator
# All-args constructor (Java) ## Insert Point As constructor(s) in class body, after fields. ## Code ```defaults // Default: all-args constructor only (when isMutable=false). // When isMutable=true, BOTH a no-args and an all-args constructor are // emitted. The skill MUST generate both even if the user did not explicitly // ask for the no-args one. // Indentation: Use the project's detected indent unit (see `SKILL.md` § Indentation). ``` **Immutable (isMutable=false) -- all-args constructor only:** ```java public {className}({Type1} {field1}, {Type2} {field2}) { this.{field1} = {field1}; this.{field2} = {field2}; } ``` **Mutable (isMutable=true) -- BOTH no-args and all-args constructors:** ```java public {className}() { } public {className}({Type1} {field1}, {Type2} {field2}) { this.{field1} = {field1}; this.{field2} = {field2}; } ``` ## Formatting rules - One blank line between the no-args and the all-args constructor (mutable case). - Constructor parameters all on a single line — no per-parameter wrapping, even for many fields. ## Variables | Variable | Source | Default | |----------|--------|---------| | `{className}` | DTO class name | -- | | `{fieldN}` | field names from selected entity attributes | -- | | `{TypeN}` | field types from selected entity attributes | -- | # equals() and hashCode() with Hibernate proxy support (Java) ## Insert Point As methods in class body, after getters/setters. ## When to use Use this variant INSTEAD of `equals-hashcode.md` when **all** of: - Hibernate is on the classpath (`presentDeps` contains `hibernate-core`). - The user explicitly opted in to proxy-aware equals (variant question "Hibernate-proxy aware equals?" answered "yes"). If either condition is false, use the plain `equals-hashcode.md`. ## Code ```defaults // Default: skip. Use only when conditions above are met. ``` ```java @Override public boolean equals(Object o) { if (this == o) return true; if (o == null) return false; Class<?> oEffectiveClass = o instanceof org.hibernate.proxy.HibernateProxy ? ((org.hibernate.proxy.HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass(); Class<?> thisEffectiveClass = this instanceof org.hibernate.proxy.HibernateProxy ? ((org.hibernate.proxy.HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass(); if (thisEffectiveClass != oEffectiveClass) return false; {className} entity = ({className}) o; return java.util.Objects.equals(this.{field1}, entity.{field1}) && java.util.Objects.equals(this.{field2}, entity.{field2}); } @Override public int hashCode() { return this instanceof org.hibernate.proxy.HibernateProxy ? ((org.hibernate.proxy.HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode(); } ``` ## FQN handling Shorten `org.hibernate.proxy.HibernateProxy` in the body and add a single `import org.hibernate.proxy.HibernateProxy;` line. ## Variables | Variable | Source | Default | |----------|--------|---------| | `{className}` | DTO class name | -- | | `{fieldN}` | field names from selected entity attributes | -- | # equals() and hashCode() (Java) ## Insert Point As methods in class body, after getters/setters. ## Code ```defaults // Default: generated (isEqualsHashCode=true by default). // Use the plain variant unless Hibernate is on the classpath AND the user // asked for proxy-aware equals -- then use the Hibernate-proxy variant from // equals-hashcode-hibernate.md. // Indentation: Use the project's detected indent unit (see `SKILL.md` § Indentation). ``` ```java @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; {className} entity = ({className}) o; return java.util.Objects.equals(this.{field1}, entity.{field1}) && java.util.Objects.equals(this.{field2}, entity.{field2}); } @Override public int hashCode() { return java.util.Objects.hash({