Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR: operator does not exist: character varying = bytea

I have a table in postgres with the following structure

CREATE TABLE rpaul."HK_LOGIN_DETAILS"
(
  "HK_LOGIN_DETAILS_ID" bigint NOT NULL,
  "HK_LOGIN_DETAILS_USERNAME" character varying(10) NOT NULL,
  "HK_LOGIN_DETAILS_PASSWORD" character varying(50) NOT NULL,
  CONSTRAINT "HK_LOGIN_DETAILS_PK" PRIMARY KEY ("HK_LOGIN_DETAILS_ID" ),
  CONSTRAINT "HK_LOGIN_DETAILS_UK" UNIQUE ("HK_LOGIN_DETAILS_USERNAME" )
)

And hibernate mapping for this table is as mentioned below

<hibernate-mapping package="net.rpaul.projects.homekeeping.domain.login">
    <class name="LoginDetails" table="`HK_LOGIN_DETAILS`">
        <id name="id" column="`HK_LOGIN_DETAILS_ID`" type="long">
            <generator class="assigned" />
        </id>
        <property name="userName" type="string" column="`HK_LOGIN_DETAILS_USERNAME`" not-null="true" />
        <property name="password" type="string" column="`HK_LOGIN_DETAILS_PASSWORD`" not-null="true" />
    </class>
</hibernate-mapping>

In the LoginDetails.java, I have declared id field as long, userName and password fields as String. Still when I try to execute the following

List list =  getHibernateTemplate().find("from LoginDetails ld where ld.userName = ?", userName);

I get

ERROR: operator does not exist: character varying = bytea

I am not getting what has went wrong. Any help would be appreciated.

like image 528
rajshekhar Avatar asked May 11 '12 06:05

rajshekhar


2 Answers

I think you should check that your variable "userName" is not null. I experienced this message in cases like that.

like image 176
chavocarlos Avatar answered Sep 16 '22 13:09

chavocarlos


It seems that Hibernate is for some reason sending the type-parameter as bytea (or rather, probably java.sql.Types.BLOB), instead of leaving it for the server to infer or setting it to text (java.sql.Types.STRING). Here is similar issue with solution JPA lower() function on parameter

like image 37
Sergey Ponomarev Avatar answered Sep 16 '22 13:09

Sergey Ponomarev