Hibernate. Configurar charset do firebird

1 resposta
R

Pessoal,
no meu banco firebird eu uso o charset ISO-8859-1.
Como eu configuro isso no hibernate?

Já tentei colocar no hibernate.properties:

hibernate.connection.charset = “ISO8859_1”
hibernate.connection.charset = ISO8859_1
hibernate.connection.charset = “ISO-8859-1”
hibernate.connection.lc_type= “ISO8859_1”
hibernate.connection.lc_type = ISO8859_1
hibernate.connection.lc_type = “ISO-8859-1”

Já tentei um tanto de coisa que nem me lembro mais. Qual é realmente a propriedade que define o charset? lc_type ou charset ou qualquer uma?

Quando eu executo a consulta, recebo o erro abaixo:

17:19:41,75017:19:41,750Exception in thread AWT-EventQueue-0 org.hibernate.exception.GenericJDBCException: could not execute query

at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)

at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)

at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)

at org.hibernate.loader.Loader.doList(Loader.java:1518)

at org.hibernate.loader.Loader.list(Loader.java:1498)

at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:369)

at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:266)

at org.hibernate.impl.SessionImpl.list(SessionImpl.java:788)

at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)

at src.model.GerenciadorCliente.getClientes(GerenciadorCliente.java:25)

at src.controller.ControladorTelaPesquisaCliente$1.actionPerformed(ControladorTelaPesquisaCliente.java:25)

at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)

at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)

at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)

at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)

at java.awt.Component.processMouseEvent(Component.java:5488)

at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)

at java.awt.Component.processEvent(Component.java:5253)

at java.awt.Container.processEvent(Container.java:1966)

at java.awt.Component.dispatchEventImpl(Component.java:3955)

at java.awt.Container.dispatchEventImpl(Container.java:2024)

at java.awt.Component.dispatchEvent(Component.java:3803)

at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)

at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)

at java.awt.Container.dispatchEventImpl(Container.java:2010)

at java.awt.Window.dispatchEventImpl(Window.java:1766)

at java.awt.Component.dispatchEvent(Component.java:3803)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

Caused by: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544321. arithmetic exception, numeric overflow, or string truncation

Cannot transliterate character between character sets

at org.firebirdsql.jdbc.FBStatementFetcher.fetch(FBStatementFetcher.java:198)

at org.firebirdsql.jdbc.FBStatementFetcher.next(FBStatementFetcher.java:110)

at org.firebirdsql.jdbc.FBResultSet.next(FBResultSet.java:223)

at com.mchange.v2.c3p0.impl.NewProxyResultSet.next(NewProxyResultSet.java:2832)

at org.hibernate.loader.Loader.doQuery(Loader.java:383)

at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:206)

at org.hibernate.loader.Loader.doList(Loader.java:1515)

 31 more

1 Resposta

R

Pessoal,
consegui resolver o problema acrescentando no hibernate.properties a linha:
hibernate.connection.[color=blue]lc_ctype[/color]= “ISO8859_1” e não
hibernate.connection.[color=red]lc_type[/color]= “ISO8859_1”

Mas ainda tenho um problema ao fazer a consulta. Agora não está mais dando erro. Mas a consulta não está devolvendo o resultado esperado.
Eu passo “João” como parâmetro e não está retornando os registros que deveria retornar.

public static List<Cliente> getClientes(String nome){ if (nome != null && nome.trim() != ""){ Session session = HibernateUtil.getSession(); nome = nome.trim().toUpperCase()+'%'; try { List<Cliente> clientes = session.createQuery("from Cliente where upper(nome) like :nome order by nome") .setParameter("nome",nome) .list(); return clientes; } finally { session.close(); } } return null; }

Criado 28 de abril de 2005
Ultima resposta 2 de mai. de 2005
Respostas 1
Participantes 1