Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Error with a hibernate query

9 views
Skip to first unread message

Vernon

unread,
Apr 14, 2005, 8:16:06 PM4/14/05
to

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.BadSqlGrammarException: 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(QueryExecutorImpl.java:1160)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:172)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:387)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:328)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:238)
at
org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
at
net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.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.doQueryAndInitializeNonLazyCollections(Loader.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

unread,
Apr 14, 2005, 8:33:45 PM4/14/05
to
Do you have a hibernate mapping file ?

Dave

Vernon wrote:

--
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

David Gagnon

unread,
Apr 18, 2005, 9:00:03 AM4/18/05
to
Hi all,

I just ran into what i think is a compliance problem. I can't call ResultSet.relative(0) without getting in exception. As stated in the javadoc it's should just do NOTHING.


Am I wrong?

Best regards
/David

rs.relative(skipResults);

if (index==0)
> throw new SQLException("Cannot move to index of 0");


/**
* Moves the cursor a relative number of rows, either positive or
negative.
* Attempting to move beyond the first/last row in the
* result set positions the cursor before/after the
* the first/last row. Calling <code>relative(0)</code> is valid,
but does
* not change the cursor position.
*
* <p>Note: Calling the method <code>relative(1)</code>
* is identical to calling the method <code>next()</code> and
* calling the method <code>relative(-1)</code> is identical
* to calling the method <code>previous()</code>.
*
* @param rows an <code>int</code> specifying the number of rows to
* move from the current row; a positive number moves the cursor
* forward; a negative number moves the cursor backward
* @return <code>true</code> if the cursor is on a row;
* <code>false</code> otherwise
* @exception SQLException if a database access error occurs,
* there is no current row, or the result set type is
* <code>TYPE_FORWARD_ONLY</code>
* @since 1.2
*/

Kris Jurka

unread,
Apr 18, 2005, 2:32:22 PM4/18/05
to

On Mon, 18 Apr 2005, David Gagnon wrote:

> I just ran into what i think is a compliance problem. I can't call
> ResultSet.relative(0) without getting in exception. As stated in the
> javadoc it's should just do NOTHING.

This is a bug and is only present in the 7.4 tree. I've fixed it there.
I'll gather up a couple more 7.4 changes and put out a new 7.4 release in
a couple of days. For now I can offer you
http://www.ejurka.com/pgsql/jars/dgagnon/pg74-dg-jdbc3.jar as I don't
happen to have other compilers available.

Kris Jurka

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

David Gagnon

unread,
Apr 18, 2005, 2:58:42 PM4/18/05
to
Thanks!

I also try a rs.relative(-1) when I was positionned before the
first row. I was not eable to get my result after that. I'm note sure
about this one though.. And it's not easy to test it agains ... I you
don't know about this one .. it's either a mistake I made myself or
another bug. If you want I cant test it when I have a chance...

Let me know!
Thanks again
/David

0 new messages