1

I have updated project from spring 3.2 to 4.1 and hibernate 4.2 to 4.3.7 and got interesting problem. I have query:

function parameter: String email;
getQuery(getSelect() + "where lower(o.email) = lower(:email)").setParameter("email", email);

now, on getting result I got

org.postgresql.util.PSQLException: ERROR: function lower(bytea) does not exist Hint: No function matches the given name and argument types. You might need to add explicit type casts.

but if I call

getQuery(getSelect() + "where lower(o.email) = lower('test')")

or

getQuery(getSelect() + "where lower(o.email) = lower(:email)").setParameter("email", "test")

it works fine.

Sergey Ponomarev
  • 2,947
  • 1
  • 33
  • 43
ekitru
  • 172
  • 1
  • 5
  • 16
  • 1
    Does it work when you explicitly specify parameter type, eg. `setParameter("email", email, StringType.INSTANCE)` ? – Bohuslav Burghardt Dec 27 '14 at 00:41
  • Weird issue. 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`). – Craig Ringer Dec 27 '14 at 06:38
  • so why not look in the log at what is the SQL that it is trying to use? I've used that type of syntax in the JPA implementation I use (DataNucleus) and had no problems – Neil Stockton Dec 27 '14 at 08:45

1 Answers1

0

setParameter("email", email, StringType.INSTANCE) - solved my issue, thanks for help!

ekitru
  • 172
  • 1
  • 5
  • 16