ERROR: operator does not exist: character varying = bytea

hibernate, postgresql

Solution

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

Problem

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.

Original source