Home > Archive > PostgreSQL JDBC > April 2005 > Error with a hibernate query









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Error with a hibernate query
Vernon

2005-04-14, 8:24 pm


The Java code:

public class User {

private Long id;
private String username;
private String password;

//...
}

The DB table:

create table USERS (
id SERIAL UNIQUE primary key,
username VARCHAR(80) NOT NULL,
password VARCHAR(80)
NOT NULL,
...
);

The Hibernate query:

getHibernateTemplate
().findByNamedParam("select u from
User as u where u.username=:username and
u.password=:password", new String[] { "username",
"password" }

From the stack, the following error seems to be on the
JDBC driver side. Any suggestions of solving this
problem?


org.springframework.jdbc. BadSqlGrammarExcepti
on: Bad
SQL grammar [] in task 'Hibernate operation'; nested
exception is java.sql.SQLException: ERROR: operator
does not exist: character varying = bytea
java.sql.SQLException: ERROR: operator does not exist:
character varying = bytea
at
org.postgresql.core.v3.QueryExecutorImpl. receiveErrorResponse
(QueryExecutorImpl.java:1365)
at
org.postgresql.core.v3.QueryExecutorImpl. processResults(Query
ExecutorImpl.java:1160)
at
org.postgresql.core.v3.QueryExecutorImpl. execute(QueryExecuto
rImpl.java:172)
at
org.postgresql.jdbc2. AbstractJdbc2Stateme
nt. execute(AbstractJdbc
2Statement.java:387)
at
org.postgresql.jdbc2. AbstractJdbc2Stateme
nt. executeWithFlags(Abs
tractJdbc2Statement.java:328)
at
org.postgresql.jdbc2. AbstractJdbc2Stateme
nt. executeQuery(Abstrac
tJdbc2Statement.java:238)
at
org.apache.commons.dbcp. DelegatingPreparedSt
atement. executeQuery(Delegat
ingPreparedStatement
.java:92)
at
net.sf.hibernate.impl.BatcherImpl. getResultSet(Batcher
Impl.java:88)
at
net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
at
net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
at
net.sf.hibernate.loader.Loader. doQueryAndInitialize
NonLazyCollections(L
oader.java:133)
at
net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at
net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at
net.sf.hibernate.hql.QueryTranslator. list(QueryTranslator
.java:854)
at
net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1553)
at
net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at



____________________
______________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Dave Cramer

2005-04-14, 8:24 pm

Do you have a hibernate mapping file ?

Dave

Vernon wrote:

>The Java code:
>
>public class User {
>
> private Long id;
> private String username;
> private String password;
>
> //...
>}
>
>The DB table:
>
>create table USERS (
> id SERIAL UNIQUE primary key,
> username VARCHAR(80) NOT NULL,
> password VARCHAR(80
) NOT NULL,
> ...
> );
>
>The Hibernate query:
>
> getHibernateTemplate
().findByNamedParam("select u from
> User as u where u.username=:username and
>u.password=:password", new String[] { "username",
>"password" }
>
>JDBC driver side. Any suggestions of solving this
>problem?
>
>
>org.springframework.jdbc. BadSqlGrammarExcepti
on: Bad
>SQL grammar [] in task 'Hibernate operation'; nested
>exception is java.sql.SQLException: ERROR: operator
>does not exist: character varying = bytea
>java.sql.SQLException: ERROR: operator does not exist:
>character varying = bytea
> at
>org.postgresql.core.v3.QueryExecutorImpl. receiveErrorResponse
(QueryExecutorImpl.java:1365)
> at
>org.postgresql.core.v3.QueryExecutorImpl. processResults(Query
ExecutorImpl.java:1160)
> at
>org.postgresql.core.v3.QueryExecutorImpl. execute(QueryExecuto
rImpl.java:172)
> at
>org.postgresql.jdbc2. AbstractJdbc2Stateme
nt. execute(AbstractJdbc
2Statement.java:387)
> at
>org.postgresql.jdbc2. AbstractJdbc2Stateme
nt. executeWithFlags(Abs
tractJdbc2Statement.java:328)
> at
>org.postgresql.jdbc2. AbstractJdbc2Stateme
nt. executeQuery(Abstrac
tJdbc2Statement.java:238)
> at
>org.apache.commons.dbcp. DelegatingPreparedSt
atement. executeQuery(Delegat
ingPreparedStatement
.java:92)
> at
>net.sf.hibernate.impl.BatcherImpl. getResultSet(Batcher
Impl.java:88)
> at
>net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
> at
>net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
> at
>net.sf.hibernate.loader.Loader. doQueryAndInitialize
NonLazyCollections(L
oader.java:133)
> at
>net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
> at
>net.sf.hibernate.loader.Loader.list(Loader.java:1024)
> at
>net.sf.hibernate.hql.QueryTranslator. list(QueryTranslator
.java:854)
> at
>net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1553)
> at
>net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
> at
>
>
>
> ____________________
______________
>Do you Yahoo!?
>Yahoo! Small Business - Try our new resources site!
>http://smallbusiness.yahoo.com/resources/
>
>---------------------------(end of broadcast)---------------------------
>TIP 4: Don't 'kill -9' the postmaster
>
>
>
>


--
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com