Landister
Landister

Reputation: 2224

ERROR: operator does not exist: character varying = numeric

So I keep getting the title error. The string I am using to create the query is,

  select p from Product p where  p.productType.productTypeId in (:productTypeIds)

And here is a clip of the java

    List<Long>partTerminologyIds = getProducTypeds(partTerminologys);
    ..........................................................................
    query.setParameter("partTerminologyIds", productTypeIds);

I have no idea why I am getting this error, ane yes partTerminolgyId in my database is a numeric 18.

Any ideas???

Upvotes: 3

Views: 7830

Answers (3)

Landister
Landister

Reputation: 2224

So in the end it ended up being that a "foreign key" was a string in one table and an numeric in the other. I rebuilt the database with new scripts and did not reverse engineer the new database.

Upvotes: 4

Erwin Brandstetter
Erwin Brandstetter

Reputation: 656231

This query is invalid:

select p from Product p where  p.productType.productTypeId in (:productTypeIds)

Do you mean:

SELECT p FROM product p WHERE p.productTypeId IN (:productTypeIds)

Or rather:

SELECT * FROM product p WHERE p.productTypeId IN (:productTypeIds)

And if so, what is the data type of productTypeId in your query. Please clarify.

Upvotes: 1

araqnid
araqnid

Reputation: 133392

This looks like a Hibernate query. You need to do query.setParameterList to specify a collection value, otherwise Hibernate won't know to expand out :productTypeIds to a list of placeholders instead of simply binding the list as a serializable blob (which I think is an awful default).

Upvotes: 0

Related Questions