我想使用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)