运算符不存在:text = bigint

问题描述 投票:0回答:3

我正在尝试让当前在 glassfish 2.1 上运行的应用程序在 jboss 6.1 上运行。并且有以下问题,我认为它与应用程序服务器无关,而是与 postgres 和/或 hibernate 有关。

使用以下软件Postgresql 9.0,jboss上使用hibernate 3.6.6,glassfish上使用3.2

无论如何,问题来了。

此命名查询:

    @NamedQuery(name="entry.updateDuplicate",
    query="UPDATE entry SET timestamp = :timestamp WHERE username = :username AND searchDocument = :searchDocument")

此代码:

    Query query = em.createNamedQuery("Entry.updateDuplicate");
    query.setParameter("timestamp", new Date(System.currentTimeMillis()));
    query.setParameter("username", username);
    query.setParameter("sDocument", sString);

    int affected = query.executeUpdate();

在日志中生成此错误:

    10:28:16,149 INFO  [STDOUT] Hibernate: update fu set c_timestamp=? where c_username=? and c_document=?
    10:28:16,165 WARN  [org.hibernate.util.JDBCExceptionReporter] SQL Error: 0, SQLState: 42883
    10:28:16,165 ERROR [org.hibernate.util.JDBCExceptionReporter] ERROR: operator does not exist: text = bigint
    Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
    Position: 77

表格是这样的:

    TABLE fu
    (
    id bigint NOT NULL, document text, timestamp timestamp without time zone, username character varying(255), CONSTRAINT fu_pkey PRIMARY KEY (c_id)
    )

任何人都有任何想法,对我来说,它似乎与“id”(唯一的 bigInt 字段)有关,但我不知道为什么或如何开始解决它。

欢迎任何建议!

hibernate postgresql jboss glassfish
3个回答
6
投票

您发布的表定义包含

document text
,那么 searchDocument 是否是一个用
@Lob
注释的字符串?在这种情况下,这可能是您在 JBoss 上使用的 Hibernate 版本的问题:

http://www.shredzone.de/cilla/page/299/string-lobs-on-postgresql-with-hibernate-36.html


2
投票

驱动程序无法将 java

long
转换为 SQL
text
(postgres 是这样严格的)。

变量

sString
的类型是什么?我怀疑它是
long
,而不是
String
,但它必须是
String

顺便说一句,

new Date(System.currentTimeMillis())
相当于
new Date()


0
投票

名称查询参数是

searchDocument
,但您设置了参数
sDocument
。实际参数 variable 被命名为
sString
,这表明它不是数字类型。尝试使用诸如
long
Long
(或
int
/
Integer
)之类的内容。

© www.soinside.com 2019 - 2024. All rights reserved.