相关疑难解决方法(0)

long类型的错误值: - Postgresql,Hibernate,Spring

我想使用Spring MVC和Hibernate在PostgresQL中存储一个实体(一个String +一个图像)这是我的表.该图像应该是oid的类型.

CREATE TABLE document
(
  name character varying(200),
  id serial NOT NULL,
  content oid,   // that should be the image
  CONSTRAINT document_pkey PRIMARY KEY (id )
)
WITH (
  OIDS=FALSE
);
Run Code Online (Sandbox Code Playgroud)

这是我想要存储的实体.

    @Entity
    @Table(name = "document")
    public class Document {

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

        @Column(name = "name")
        private String name;

        @Column(name="content")
            private Blob content;  //this is the image
//getters- setters
Run Code Online (Sandbox Code Playgroud)

您可以看到变量"name"是String,而不是Long.仍然当我提交一个不是数字的值的表单时,它会抛出 org.postgresql.util.PSQLException: Bad value for type long : x

这是表格:

<form:form method="post" …
Run Code Online (Sandbox Code Playgroud)

java postgresql spring hibernate blob

14
推荐指数
3
解决办法
2万
查看次数

标签 统计

blob ×1

hibernate ×1

java ×1

postgresql ×1

spring ×1