0

i try to use native query and i get above error: column "code" is of type smallint but expression is of type bytea, does anyone know how to fix it? i tried to use CAST to numeric but it doesn't work.

    entityManager.createQuery(
                    "INSERT INTO car("http_code) " +
                            "VALUES(":httpCode)")
            .setParameter("code", entity.getCode)
            .executeUpdate();
pawello12
  • 17
  • 5
  • Do it in your application and supply the correct type. I suspect you database adapter code is translating `getCode` as a byte array. – Richard Huxton Jun 26 '23 at 17:08
  • There seems to be issues with double-quotes and missing parentheses in this code sample – Bruno Jun 26 '23 at 17:17
  • the problem is that I have int2 in the database and Short in the entity, so the types should match – pawello12 Jun 26 '23 at 17:57
  • Does `getCode()` return a `Short`? It would be good if you cleaned up those few lines of code. As it stands, it would have syntax errors, so it makes it harder to know where the problem could come from. – Bruno Jun 26 '23 at 19:57

0 Answers0