Panache Entity & REST Generator
Panache Entity & REST Generator
Section titled “Panache Entity & REST Generator”Writing repetitive boilerplate for entities, DTOs, repositories, and JAX-RS CRUD endpoints is tedious. Quarkus Studio provides an end-to-end generator to scaffold production-ready code with best practices.
🚀 Generation Input Modes
Section titled “🚀 Generation Input Modes”You can invoke the generator from the Command Palette or by right-clicking in the Explorer:
- Interactive Wizard: Prompts you for entity name, field definitions (e.g.
name:String, price:BigDecimal, inStock:Boolean), and pattern preferences. - JSON Sample Payload: Right-click any
.jsonsample payload to infer Java field names and types (including nested objects, UUIDs, dates, and numbers). - SQL / DDL Schema Parser: Right-click any
.sqlschema script containingCREATE TABLEstatements. Quarkus Studio maps SQL types (BIGSERIAL,VARCHAR,TIMESTAMP,DECIMAL) to Java types and convertssnake_casecolumn names tocamelCaseproperties with@Column(name = "...").
🏛️ Architectural Patterns
Section titled “🏛️ Architectural Patterns”Quarkus Studio lets you choose your preferred architecture:
Idiomatic Quarkus style extending PanacheEntity:
package com.example.domain;
import io.quarkus.hibernate.orm.panache.PanacheEntity;import jakarta.persistence.Entity;import jakarta.persistence.Table;import java.math.BigDecimal;
@Entity@Table(name = "products")public class Product extends PanacheEntity { public String name; public BigDecimal price; public Boolean inStock;
public static Product findByName(String name) { return find("name", name).firstResult(); }}Traditional Domain-Driven Design (DDD) with an @Entity and companion @ApplicationScoped repository:
package com.example.repository;
import com.example.domain.Product;import io.quarkus.hibernate.orm.panache.PanacheRepository;import jakarta.enterprise.context.ApplicationScoped;
@ApplicationScopedpublic class ProductRepository implements PanacheRepository<Product> { public Product findByName(String name) { return find("name", name).firstResult(); }}📦 Modern Java 17+ Record DTOs
Section titled “📦 Modern Java 17+ Record DTOs”Quarkus Studio generates immutable Java record classes with bidirectional mapping helpers:
package com.example.dto;
import com.example.domain.Product;import java.math.BigDecimal;
public record ProductDTO(Long id, String name, BigDecimal price, Boolean inStock) { public static ProductDTO fromEntity(Product entity) { return new ProductDTO(entity.id, entity.name, entity.price, entity.inStock); }
public Product toEntity() { Product entity = new Product(); entity.name = this.name(); entity.price = this.price(); entity.inStock = this.inStock(); return entity; }
public void updateEntity(Product entity) { entity.name = this.name(); entity.price = this.price(); entity.inStock = this.inStock(); }}⚡ Complete REST CRUD Endpoints
Section titled “⚡ Complete REST CRUD Endpoints”Along with models and DTOs, Quarkus Studio creates full JAX-RS / Quarkus REST endpoints under @Path("/api/<entities>"):
GET /api/products- Returns list of all products mapped to DTOs.GET /api/products/{id}- Returns single item or404 Not Found.POST /api/products-@Transactionalcreation endpoint returning201 CreatedwithLocationheader.PUT /api/products/{id}- Updates entity fields.DELETE /api/products/{id}- Removes entity and returns204 No Content.
