postgresql 运算符不存在:text = bigint
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9464153/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Operator does not exist: text = bigint
提问by linusno
I am trying to get our application that is currently running on glassfish 2.1 to work on jboss 6.1. And have the following problem, I don't think its related to the application server but rather something to do with postgres and /or hibernate.
我试图让我们目前在 glassfish 2.1 上运行的应用程序在 jboss 6.1 上运行。并且有以下问题,我认为它与应用程序服务器无关,而是与 postgres 和/或休眠有关。
Using the following software Postgresql 9.0, hibernate 3.6.6 on jboss and 3.2 on glassfish
使用以下软件 Postgresql 9.0,在 jboss 上休眠 3.6.6,在 glassfish 上休眠 3.2
Anyway, the problem.
总之,问题。
this named query:
这个命名查询:
@NamedQuery(name="entry.updateDuplicate",
query="UPDATE entry SET timestamp = :timestamp WHERE username = :username AND searchDocument = :searchDocument")
this code:
这段代码:
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();
generates this fault in the log:
在日志中生成此错误:
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
the table is this:
表是这样的:
TABLE fu
(
id bigint NOT NULL, document text, timestamp timestamp without time zone, username character varying(255), CONSTRAINT fu_pkey PRIMARY KEY (c_id)
)
Anyone have any idea, to me it seams like it has something to do with 'id' (the only bigInt field) but I can't figure out why or how to begin to solve it.
任何人都有任何想法,对我来说,它似乎与“id”(唯一的 bigInt 字段)有关,但我不知道为什么或如何开始解决它。
Any suggestion is most welcome!
任何建议都是最受欢迎的!
回答by E.B.
The table definition that you posted contains document text
, so is searchDocument by any chance a String annotated with @Lob
? In that case this might be an issue with the Hibernate version that you're using on JBoss:
您发布的表定义包含document text
,那么 searchDocument 有没有可能是一个用 注释的字符串@Lob
?在这种情况下,这可能是您在 JBoss 上使用的 Hibernate 版本的问题:
http://www.shredzone.de/cilla/page/299/string-lobs-on-postgresql-with-hibernate-36.html
http://www.shredzone.de/cilla/page/299/string-lobs-on-postgresql-with-hibernate-36.html
回答by A.H.
The names query parameter is searchDocument
but you set the parameter sDocument
. And the actual paramater variableis named sString
which suggests, that it is not a numeric type. Try something like long
or Long
(or int
/ Integer
) instead.
名称查询参数是searchDocument
但您设置了参数sDocument
。实际的参数变量被命名sString
,这表明它不是数字类型。尝试类似long
或Long
(或int
/ Integer
)之类的东西。
回答by Bohemian
The driver can't convert a java long
to SQL text
(postgres is stupid like that).
驱动程序无法将 java 转换long
为 SQL text
(postgres 就是这样愚蠢)。
What is the type of variable sString
? I suspect it's a long
, not a String
, but it needs to be a String
.
变量的类型是sString
什么?我怀疑它是一个long
,而不是一个String
,但它需要是一个String
.
As an aside, new Date(System.currentTimeMillis())
is equivalent to just new Date()
顺便说一句,new Date(System.currentTimeMillis())
相当于只是new Date()