加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql – 接缝文件上传到postgres bytea列“列是bytea但表

发布时间:2020-12-13 18:06:14 所属栏目:百科 来源:网络整理
导读:紧随 this example之后,我正在上传一个小文件并尝试存储到postgresql bytea列中. 这是错误(前两个输出是在尝试INSERT之前输出bean属性的日志语句: SAGE 1 — action.registration.LetterTemplateHome – content type: text/xml SAGE 1 — action.registrat
紧随 this example之后,我正在上传一个小文件并尝试存储到postgresql bytea列中.

这是错误(前两个输出是在尝试INSERT之前输出bean属性的日志语句:

SAGE 1 — action.registration.LetterTemplateHome – content type: text/xml

SAGE 1 — action.registration.LetterTemplateHome – letterTemplateText: [B@48c7aaef

SAGE 1 — action.registration.LetterTemplateHome – contents as String: xml version=”1.0″ encoding=”UTF-8″ standalone=”yes” …. etc

SAGE 1 — org.hibernate.util.JDBCExceptionReporter – Batch entry 0 insert into letter_template (content_type,file_name_template,fileSize,letter_template_name,letter_template_text,letter_template_id) values (‘text/xml’,‘letterDate.xml’,‘0’,‘yu’,‘37078’,‘202’) was aborted. Call getNextException to see the cause.

SAGE 1 — org.hibernate.util.JDBCExceptionReporter – ERROR: column “letter_template_text” is of type bytea but expression is of type bigint
Hint: You will need to rewrite or cast the expression.
Position: 162

这里是如何在bean中定义字段:

private byte[] letterTemplateText;

@Lob
@Column(name = "letter_template_text")
@Basic(fetch = FetchType.LAZY)
public byte[] getLetterTemplateText() {
    return this.letterTemplateText;
}

public void setLetterTemplateText(byte[] letterTemplateText) {
    this.letterTemplateText = letterTemplateText;
}
我怀疑Hibernate正在尝试使用PostgreSQL的“大对象”方法,该方法涉及将OID“句柄”存储到表中的文件中.一些例子阅读: http://virgo47.wordpress.com/2008/06/13/jpa-postgresql-and-bytea-vs-oid-type/

如果您想坚持使用bytea列(这在SQL端使用起来相当简单),请使用BinaryType映射列.见:proper hibernate annotation for byte[]

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读