Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

292
Visualizações
Native query not working in hibernate

I have an issue with my native query.

I've got:

@Query(value="SELECT * from orders where orders.house in ((:houseArray))", nativeQuery = true)
    List<Order> findByHouseId(@Param("houseArray") List<Long> houseArray);

And when I am trying to execute, I get the following:

2017-04-18 14:19:49,736 DEBUG org.hibernate.SQL: SELECT * from orders where orders.house in ((?, ?, ?, ?, ?))
2017-04-18 14:19:49,737 TRACE o.h.t.d.s.BasicBinder: binding parameter [2] as [BIGINT] - [4]
2017-04-18 14:19:49,737 TRACE o.h.t.d.s.BasicBinder: binding parameter [3] as [BIGINT] - [5]
2017-04-18 14:19:49,737 TRACE o.h.t.d.s.BasicBinder: binding parameter [1] as [BIGINT] - [3]
2017-04-18 14:19:49,737 TRACE o.h.t.d.s.BasicBinder: binding parameter [4] as [BIGINT] - [6]
2017-04-18 14:19:49,737 TRACE o.h.t.d.s.BasicBinder: binding parameter [5] as [BIGINT] - [7]
2017-04-18 14:19:49,738 ERROR o.h.e.j.s.SqlExceptionHelper: ERROR: operator does not exist: bigint = record
  Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
  Position: 49
2017-04-18 14:19:49,756 ERROR o.a.c.c.C.[.[.[.[dispatcherServlet]: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause
org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = record
  Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.

However, if I run the following query in console:

SELECT * from orders where orders.house in (1,15,2,4,5,3,6,7);

It returns proper list of orders.

How can I fix this?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Try removing one set of brackets from ((:houseArray)) so it looks like that:

@Query(value="SELECT * from orders where orders.house in (:houseArray)", nativeQuery = true)
List<Order> findByHouseId(@Param("houseArray") List<Long> houseArray);

(value, value, value) is a record, so when you do column in ((value, value, value)) you compare column vs record.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda