Olá!
Estou tentando mapear um campo chamdo "fields" do tipo JSONB no Postgres na minha classe de entidade do spring boot 3.3.3, mas está gerando erro na compilação.
Minha classe de entidade:
package com.meusite.api.entity;
import java.time.LocalDateTime;
import com.meusite.api.enums.Status;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.JsonNode;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Data
@Entity
public class DocumentModel {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@NotNull
@Temporal(TemporalType.TIMESTAMP)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime dateCreated = LocalDateTime.now();
@Temporal(TemporalType.TIMESTAMP)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime dateUpdated;
@Column(length = 200, nullable = false)
private String name;
private String description;
private JsonNode fields;
@ManyToOne(optional = false)
@JoinColumn(name = "company_id")
private Company company;
@NotNull(message = "Status nao deve ser nulo")
@Enumerated(EnumType.STRING)
private Status status = Status.ACTIVE;
}
Qual seria a maneira correta de mapear o campo?