gpt4 book ai didi

postgresql - seam 文件上传到 postgres bytea 列 "column is bytea but expression is of type bigint"

转载 作者:行者123 更新时间:2023-11-29 11:24:50 36 4
gpt4 key购买 nike

紧随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;
}

最佳答案

对我来说,它在 Postgres 数据库中使用 bytea 类型。

@Lob
@Type(type="org.hibernate.type.BinaryType")
@Column(name = "photo")
private byte[] photo;

//and get and set

关于postgresql - seam 文件上传到 postgres bytea 列 "column is bytea but expression is of type bigint",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9114510/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com