Schemint

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

PostgreSQL CREATE TABLE to JPA Entity (Spring Boot)

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

Paste a PostgreSQL CREATE TABLE and get a Spring Boot 3 (Jakarta) JPA @Entity: @Id and @GeneratedValue on the key, @Column carrying nullable, unique and length, and BigDecimal for NUMERIC so money math stays exact.

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

Try it on your own schema

Example

PostgreSQL in:

CREATE TABLE product (
    id BIGSERIAL PRIMARY KEY,
    sku VARCHAR(40) UNIQUE NOT NULL,
    name VARCHAR(200) NOT NULL,
    price NUMERIC(12, 2) NOT NULL,
    in_stock BOOLEAN NOT NULL DEFAULT true,
    created_at TIMESTAMP NOT NULL DEFAULT now()
);

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 = true;

    @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