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.
I think you should check that your variable "userName" is not null. I experienced this message in cases like that.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With