Schemint

paste PostgreSQL or JSON, get your schema reviewed like a senior would

MySQL CREATE TABLE to JPA Entity (Spring Boot)

Paste a CREATE TABLE, get a JPA Entity. Nothing you paste is stored.

Paste a MySQL CREATE TABLE and get a Spring Boot 3 (Jakarta) JPA @Entity: AUTO_INCREMENT becomes @Id with @GeneratedValue, @Column carries nullable, unique and length, TINYINT(1) maps to Boolean and DECIMAL to BigDecimal so money math stays exact.

Mapped from your real DDL, on the server, discarded after the response.

Try it on your own schema

Example

MySQL in:

CREATE TABLE `product` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `sku` VARCHAR(40) NOT NULL,
    `name` VARCHAR(200) NOT NULL,
    `price` DECIMAL(12, 2) NOT NULL,
    `in_stock` TINYINT(1) NOT NULL DEFAULT 1,
    `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    UNIQUE KEY `uq_product_sku` (`sku`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Generated:

ProductEntity.java

package dev.schemint.gen;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.math.BigDecimal;
import java.time.LocalDateTime;

@Entity
@Table(name = "product")
public class ProductEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @Column(name = "sku", nullable = false, unique = true, length = 40)
    private String sku;

    @Column(name = "name", nullable = false, length = 200)
    private String name;

    @Column(name = "price", nullable = false, precision = 12, scale = 2)
    private BigDecimal price;

    @Column(name = "in_stock", nullable = false)
    private Boolean inStock;

    @Column(name = "created_at", nullable = false)
    private LocalDateTime createdAt;

    protected ProductEntity() {
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getSku() {
        return sku;
    }

    public void setSku(String sku) {
        this.sku = sku;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Boolean getInStock() {
        return inStock;
    }

    public void setInStock(Boolean inStock) {
        this.inStock = inStock;
    }

    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }

}

Related