Erro no PostGre com Hibernate

2 respostas
U

Pessoal, tive o seguinte erro ao executar a pesquisa abaixo:

public Collection listByExame(long codexa) 
{		
   Session session = null;
   List    lista   = null;
   try 
   {
      session = HibernateUtil.getSession();
      lista   = session.createQuery("from Paciente paciente " +
      "left join fetch paciente.exame exame " +
      "where exame.codexa = ?")
      .setString(0,String.valueOf(codexa))
      .list();
      HibernateUtil.closeSession();			
   } catch (HibernateException ex) {			
   throw new PersistenceException(ex);			
   }		
   return lista;
}

09:12:55,843 WARN JDBCExceptionReporter:77 - SQL Error: 0, SQLState: 42883
09:12:55,843 ERROR JDBCExceptionReporter:78 - ERROR: operator does not exist: bigint = character varying
org.hibernate.exception.SQLGrammarException: could not execute query

Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1592)

Provavelmente tem a ver com o valor LONG em Java e o BIGINT no Postgre mas não consegui entender ainda. Alguém pode me ajudar?

2 Respostas

H

cara…
você está setando uma String para um tipo Bigint do seu banco…
tente mudar para…

.setLong(0, codexa)
U

Exato, vlw.

Criado 5 de maio de 2008
Ultima resposta 5 de mai. de 2008
Respostas 2
Participantes 2