我有一个包含数据的Postgres sql数据库。我试图用我的Spring-Data-JPA项目插入Hibernate映射数据。我正在
ERROR: org.hibernate.engine.jdbc.spi.SqlExceptionHelper - ERROR: column "is_active" is of type bit varying but expression is of type oid
这是我的实体
@Entity
@Table(schema = "shard_1", name = "pages")
@XmlRootElement
@NamedQueries({ @NamedQuery(name = "Pages.findAll", query = "SELECT p FROM Pages p"),
@NamedQuery(name = "Pages.findById", query = "SELECT p FROM Pages p WHERE p.id = :id"),
@NamedQuery(name = "Pages.findByPageNumber", query = "SELECT p FROM Pages p WHERE p.pageNumber = :pageNumber"),
@NamedQuery(name = "Pages.findByTitle", query = "SELECT p FROM Pages p WHERE p.title = :title"),
@NamedQuery(name = "Pages.findBySectionId", query = "SELECT p FROM Pages p WHERE p.sectionId = :sectionId"),
@NamedQuery(name = "Pages.findByVersionId", query = "SELECT p FROM Pages p WHERE p.versionId = :versionId"),
@NamedQuery(name = "Pages.findByCreated", query = "SELECT p FROM Pages p WHERE p.created = :created"),
@NamedQuery(name = "Pages.findByModified", query = "SELECT p FROM Pages p WHERE p.modified = :modified"),
@NamedQuery(name = "Pages.findByPdfcontent", query = "SELECT p FROM Pages p WHERE p.pdfcontent = :pdfcontent") })
public class Pages implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(nullable = false)
private Long id;
@Column(name = "page_number")
private Integer pageNumber;
@Column(length = 2147483647)
private String title;
@Column(name = "section_id")
private BigInteger sectionId;
@Column(name = "version_id")
private BigInteger versionId;
@Lob
@Column(name = "is_active")
private Object isActive;
@Temporal(TemporalType.TIMESTAMP)
private Date created;
@Temporal(TemporalType.TIMESTAMP)
private Date modified;
@Column(length = 2147483647)
private String pdfcontent;
}
这是我的postgres表
CREATE TABLE shard_1.pages
(
id bigint NOT NULL DEFAULT shard_1.id_generator(),
page_number integer,
title text COLLATE pg_catalog."default",
section_id bigint,
version_id bigint,
is_active bit varying,
created timestamp without time zone,
modified timestamp without time zone,
pdfcontent text COLLATE pg_catalog."default",
CONSTRAINT pages_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE shard_1.pages
OWNER to root;
我尝试了Java数据类型boolean,string,char array,int,byte []但是失败了。我应该在这里使用is_active字段的数据类型是什么?
答案 0 :(得分:0)
尝试删除@Lob,即:
@Column(name =“is_active”) private Boolean isActive;
并改变你的桌子'shard_1.pages'就像这样:
ALTER TABLE shard_1.pages DROP COLUMN is_active; ALTER TABLE shard_1.pagese ADD COLUMN is_active boolean;